Category: Linux

acer-wmi: fix obj is NULL but dereferenced

Author: Lee, Chun-Yi <joeyli.kernel@gmail.com> Fengguang Wu run coccinelle and warns about: drivers/platform/x86/acer-wmi.c:1200:17-21: ERROR: obj is NULL but dereferenced. drivers/platform/x86/acer-wmi.c:891:17-21: ERROR: obj is NULL but dereferenced. drivers/platform/x86/acer-wmi.c:1953:17-21: ERROR: obj is NULL but dereferenced. It causes by the code in patch 987dfbaa65b2c3568b85e29d2598da08a011ee09 doesn’t check obj variable should not be NULL. There have risk for dereference a NULL …

Continue reading

[media] media: saa7146: don’t use mutex_lock_interruptible() in device_release()

Author: Cyril Roelandt <tipecaml@gmail.com> Use uninterruptible mutex_lock in the release() file op to make sure all resources are properly freed when a process is being terminated. Returning -ERESTARTSYS has no effect for a terminating process and this may cause driver resources not to be released. This was found using the following semantic patch (http://coccinelle.lip6.fr/): @r@ …

Continue reading

drivers/base/core.c: Remove two unused variables and two useless calls to kfree

Author: Peter Senna Tschudin <peter.senna@gmail.com> old_class_name, and new_class_name are never used. This patch remove the declaration and calls to kfree. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r1 forall@ type T; identifier i; @@ * T *i = NULL; … when != i * kfree(i); // Signed-off-by: Peter Senna Tschudin …

Continue reading

vfio: simplify kmalloc+copy_from_user to memdup_user

Author: Fengguang Wu <fengguang.wu@intel.com> Generated by: coccinelle/api/memdup_user.cocci Acked-by: Julia Lawall Reported-by: Fengguang Wu Signed-off-by: Alex Williamson — drivers/vfio/pci/vfio_pci.c | 13 ++++——— 1 file changed, 4 insertions(+), 9 deletions(-)   diff –git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index 6c11994..a4dc21b 100644 — a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -327,15 +327,10 @@ static long vfio_pci_ioctl(void *device_data, hdr.count > vfio_pci_get_irq_count(vdev, hdr.index)) return -EINVAL;   …

Continue reading

staging: line6: Use kmemdup rather than duplicating its implementation

Author: Laurent Navet <laurent.navet@gmail.com> staging: line6: driver.c The semantic patch that makes this output is available in scripts/coccinelle/api/memdup.cocci. Signed-off-by: Laurent Navet Signed-off-by: Greg Kroah-Hartman — drivers/staging/line6/driver.c | 5 ++— 1 file changed, 2 insertions(+), 3 deletions(-)   diff –git a/drivers/staging/line6/driver.c b/drivers/staging/line6/driver.c index 1e4ce500..71c2a57 100644 — a/drivers/staging/line6/driver.c +++ b/drivers/staging/line6/driver.c @@ -307,14 +307,13 @@ int line6_version_request_async(struct usb_line6 …

Continue reading

char/tpm: Use true and false for bools

Author: Peter Huewe <peterhuewe@gmx.de> Bool initializations should use true and false. Bool tests don’t need comparisons. Based on contributions from Joe Perches, Rusty Russell and Bruce W Allan. The semantic patch that makes this output is available in scripts/coccinelle/misc/boolinit.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Peter Huewe Signed-off-by: Kent Yoder — …

Continue reading

UBI: replace memcpy with struct assignment

Author: Ezequiel Garcia <elezegarcia@gmail.com> This kind of memcpy() is error-prone. Its replacement with a struct assignment is prefered because it’s type-safe and much easier to read. Found by coccinelle. Hand patched and reviewed. Tested by compilation only. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ identifier …

Continue reading

[SCSI] qla2xxx: Fix coccinelle warnings in qla2x00_relogin.

Author: Saurav Kashyap <saurav.kashyap@qlogic.com> Reported-by: Fengguang Wu Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap Signed-off-by: James Bottomley — drivers/scsi/qla2xxx/qla_os.c | 7 +++—- 1 file changed, 3 insertions(+), 4 deletions(-)   diff –git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 0cdc6e2..132556b 100644 — a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -3720,10 +3720,9 @@ void qla2x00_relogin(struct scsi_qla_host *vha) if (fcport->flags & FCF_FCP2_DEVICE) opts |= BIT_1; …

Continue reading

ARM: OMAP1: use BUG_ON where possible

Author: Sasha Levin <sasha.levin@oracle.com> Just use BUG_ON() instead of constructions such as: if (…) BUG() A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression e; @@ – if (e) BUG(); + BUG_ON(e); // Signed-off-by: Sasha Levin Signed-off-by: Tony Lindgren — arch/arm/mach-omap1/board-fsample.c | 3 +– arch/arm/mach-omap1/board-h2.c | …

Continue reading

ARM: integrator: use BUG_ON where possible

Author: Sasha Levin <sasha.levin@oracle.com> Just use BUG_ON() instead of constructions such as: if (…) BUG() A simplified version of the semantic patch that makes this transformation is as follows: (http://coccinelle.lip6.fr/) // @@ expression e; @@ – if (e) BUG(); + BUG_ON(e); // Signed-off-by: Sasha Levin Acked-by: Arnd Bergmann Signed-off-by: Linus Walleij — arch/arm/mach-integrator/pci_v3.c | 9 …

Continue reading