Skip to contentSkip to conversation

media: rc: fix check on dev->min_timeout for LIRC_GET_MIN_TIMEOUT ioctl

PATCH In review Colin King 2 participants 3 messages Sep 15, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 media: rc: fix check on dev->min_timeout for LIRC_GET_MIN_TIMEOUT ioctl

From: Colin Ian King <[email protected]>

Currently the LIRC_GET_MIN_TIMEOUT is checking for a null dev->max_timeout and then accessing dev->min_timeout, hence we may have a potential null pointer dereference issue. This looks like a cut-n-paste typo, fix it by checking on dev->min_timeout before accessing it.

Addresses-Coverity: ("Copy-paste error")

Fixes e589333f346b ("V4L/DVB: IR: extend interfaces to support more device settings")
---
 drivers/media/rc/lirc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +1 -1
index 220363b9a868..d230c21e1d31 100644
@@ -533,7 +533,7 @@ static long lirc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	/* Generic timeout support */
 	case LIRC_GET_MIN_TIMEOUT:
-		if (!dev->max_timeout)
+		if (!dev->min_timeout)
 			ret = -ENOTTY;
 		else
 			val = dev->min_timeout;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the LIRC_GET_MIN_TIMEOUT is checking for a null dev->max_timeout and then accessing dev->min_timeout, hence we may have a potential null pointer dereference issue. This looks like a cut-n-paste typo, fix it by checking on dev->min_timeout before accessing it.

max_timeout and min_timeout are both u32, not pointers. So, the commit message is wrong: there is no null pointer dereference issue.

Every driver which has max_timeout also has min_timeout set (I've checked for this). So technically this is not wrong, but maybe it looks wrong?

Thanks,

Sean

Quoted 23 lines

Addresses-Coverity: ("Copy-paste error")

Fixes e589333f346b ("V4L/DVB: IR: extend interfaces to support more device settings")
---
 drivers/media/rc/lirc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +1 -1
index 220363b9a868..d230c21e1d31 100644
@@ -533,7 +533,7 @@ static long lirc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	/* Generic timeout support */
 	case LIRC_GET_MIN_TIMEOUT:
-		if (!dev->max_timeout)
+		if (!dev->min_timeout)
 			ret = -ENOTTY;
 		else
 			val = dev->min_timeout;
Signature · 1 line
2.27.0
#2 lore raw
Quoted 8 lines · Sean Young
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the LIRC_GET_MIN_TIMEOUT is checking for a null dev->max_timeout and then accessing dev->min_timeout, hence we may have a potential null pointer dereference issue. This looks like a cut-n-paste typo, fix it by checking on dev->min_timeout before accessing it.

Quoted 5 lines

max_timeout and min_timeout are both u32, not pointers. So, the commit message is wrong: there is no null pointer dereference issue.

Every driver which has max_timeout also has min_timeout set (I've checked for this). So technically this is not wrong, but maybe it looks wrong?

Oops. I totally misread the analysis report. My bad.

Quoted 27 lines

Thanks,

Sean

Quoted 23 lines

Addresses-Coverity: ("Copy-paste error")

Fixes e589333f346b ("V4L/DVB: IR: extend interfaces to support more device settings")
---
 drivers/media/rc/lirc_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +1 -1
index 220363b9a868..d230c21e1d31 100644
@@ -533,7 +533,7 @@ static long lirc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	/* Generic timeout support */
 	case LIRC_GET_MIN_TIMEOUT:
-		if (!dev->max_timeout)
+		if (!dev->min_timeout)
 			ret = -ENOTTY;
 		else
 			val = dev->min_timeout;
Signature · 1 line
2.27.0