Skip to contentSkip to conversation

staging: lirc: fix NULL pointer dereference

PATCH In review Daeseok Youn 2 participants 4 messages Apr 2, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lirc: fix NULL pointer dereference

coccicheck says:
drivers/staging/media/lirc/lirc_igorplugusb.c:226:15-21:
ERROR: ir is NULL but dereferenced.

---
 drivers/staging/media/lirc/lirc_igorplugusb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_igorplugusb.c +2 -2
index f508a13..0ef393b 100644
@@ -223,8 +223,8 @@ static int unregister_from_lirc(struct igorplug *ir)
 	int devnum;
 
 	if (!ir) {
-		dev_err(&ir->usbdev->dev,
-			"%s: called with NULL device struct!\n", __func__);
+		printk(DRIVER_NAME "%s: called with NULL device struct!\n",
+		       __func__);
 		return -EINVAL;
 	}
 
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 15 lines · Daeseok Youn

coccicheck says:
drivers/staging/media/lirc/lirc_igorplugusb.c:226:15-21:
ERROR: ir is NULL but dereferenced.

---
 drivers/staging/media/lirc/lirc_igorplugusb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
index f508a13..0ef393b 100644

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 227

Quoted 7 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +2 -2
@@ -223,8 +223,8 @@ static int unregister_from_lirc(struct igorplug *ir)
 	int devnum;
 
 	if (!ir) {
-		dev_err(&ir->usbdev->dev,
-			"%s: called with NULL device struct!\n", __func__);
+		printk(DRIVER_NAME "%s: called with NULL device struct!\n",
+		       __func__);

It should be pr_err() or something. But actually "ir" can't be NULL so just delete the whole condition.

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 229

Quoted 2 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
 		return -EINVAL;
 	}

regards,
dan carpenter

#2 lore raw

You are right. remove whole thing and send it again.

Thanks.
Daeseok Youn

2014-04-02 18:13 GMT+09:00 Dan Carpenter <[email protected]>:

Quoted 35 lines · Daeseok Youn
Quoted 15 lines

coccicheck says:
drivers/staging/media/lirc/lirc_igorplugusb.c:226:15-21:
ERROR: ir is NULL but dereferenced.

---
 drivers/staging/media/lirc/lirc_igorplugusb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
index f508a13..0ef393b 100644

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 227

Quoted 7 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +2 -2
@@ -223,8 +223,8 @@ static int unregister_from_lirc(struct igorplug *ir)
      int devnum;
 
      if (!ir) {
-             dev_err(&ir->usbdev->dev,
-                     "%s: called with NULL device struct!\n", __func__);
+             printk(DRIVER_NAME "%s: called with NULL device struct!\n",
+                    __func__);

It should be pr_err() or something. But actually "ir" can't be NULL so just delete the whole condition.

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 229

Quoted 2 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
              return -EINVAL;
      }

regards,
dan carpenter

#3 lore raw

Please drop this patch.

I made a patch as Dan's comment and sent it.

Thanks.
Daeseok Youn.

2014-04-02 18:41 GMT+09:00 DaeSeok Youn <[email protected]>:

Quoted 41 lines

You are right. remove whole thing and send it again.

Thanks.
Daeseok Youn

2014-04-02 18:13 GMT+09:00 Dan Carpenter <[email protected]>:

Quoted 35 lines · Daeseok Youn
Quoted 15 lines

coccicheck says:
drivers/staging/media/lirc/lirc_igorplugusb.c:226:15-21:
ERROR: ir is NULL but dereferenced.

---
 drivers/staging/media/lirc/lirc_igorplugusb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
index f508a13..0ef393b 100644

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 227

Quoted 7 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +2 -2
@@ -223,8 +223,8 @@ static int unregister_from_lirc(struct igorplug *ir)
      int devnum;
 
      if (!ir) {
-             dev_err(&ir->usbdev->dev,
-                     "%s: called with NULL device struct!\n", __func__);
+             printk(DRIVER_NAME "%s: called with NULL device struct!\n",
+                    __func__);

It should be pr_err() or something. But actually "ir" can't be NULL so just delete the whole condition.

drivers/staging/media/lirc/lirc_igorplugusb.c static int unregister_from_lirc(struct igorplug *ir) · line 229

Quoted 2 lines
drivers/staging/media/lirc/lirc_igorplugusb.c +0 -0
              return -EINVAL;
      }

regards,
dan carpenter