Catégorie : Linux

net/wireless/nl80211.c: Avoid call to genlmsg_cancel

Author: Julia Lawall <julia@diku.dk> genlmsg_cancel subtracts some constants from its second argument before calling nlmsg_cancel. nlmsg_cancel then calls nlmsg_trim on the same arguments. nlmsg_trim tests for NULL before doing any computation, but a NULL second argument to genlmsg_cancel is no longer NULL due to the initial subtraction. Nothing else happens in this execution, so the …

Lire la suite

staging: msm/lcdc.c: Convert IS_ERR result to PTR_ERR

Author: Julia Lawall <julia@diku.dk> This code elsewhere returns a negative constant to an indicate an error, while IS_ERR returns the result of a >= operation. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; @@ if (…) { … – return IS_ERR(x); + return PTR_ERR(x); } // Signed-off-by: Julia …

Lire la suite

arch/arm/mach-omap2/dma.c: Convert IS_ERR result to PTR_ERR

Author: Julia Lawall <julia@diku.dk> This code elsewhere returns a negative constant to an indicate an error, while IS_ERR returns the result of a >= operation. The semantic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; @@ if (…) { … – return IS_ERR(x); + return PTR_ERR(x); } // Signed-off-by: Julia …

Lire la suite

OMAP: PM: SmartReflex: Add missing IS_ERR test

Author: Julia Lawall <julia@diku.dk> Function _sr_lookup, defined in the same file, returns ERR_PTR not NULL in an error case. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier f; @@ f(…) { … return ERR_PTR(…); } @@ identifier r.f, fld; expression x; statement S1,S2; @@ x = f(…) … when …

Lire la suite

drivers/video/bf537-lq035.c: Add missing IS_ERR test

Author: Julia Lawall <julia@diku.dk> lcd_device_register may return ERR_PTR, so a check is added for this value before the dereference. All of the other changes reorganize the error handling code in this function to avoid duplicating all of it in the added case. In the original code, in one case, the global variable fb_buffer was set …

Lire la suite

fs/btrfs/inode.c: Add missing IS_ERR test

Author: Julia Lawall <julia@diku.dk> After the conditional that precedes the following code, inode may be an ERR_PTR value. This can eg result from a memory allocation failure via the call to btrfs_iget, and thus does not imply that root is different than sub_root. Thus, an IS_ERR check is added to ensure that there is no …

Lire la suite

staging: Fix some incorrect use of positive error codes.

Author: Ralph Loader <suckfish@ihug.co.nz> Use -E… instead of just E… in a few places where negative error codes are expected by a functions callers. These were found by grepping with coccinelle & then inspecting by hand to determine which were bugs. The staging/cxt1e1 driver appears to intentionally use positive E… error codes in some places, …

Lire la suite

e1000e: Use kmemdup rather than duplicating its implementation

Author: Bruce Allan <bruce.w.allan@intel.com> The semantic patch that makes this output is available in scripts/coccinelle/api/memdup.cocci. More information about semantic patching is available at http://coccinelle.lip6.fr/ Signed-off-by: Bruce Allan Tested-by: Signed-off-by: Jeff Kirsher — drivers/net/e1000e/ethtool.c | 11 ++——— 1 file changed, 2 insertions(+), 9 deletions(-)   diff –git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 323fd12..daa7fe4 100644 — a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c …

Lire la suite

drivers/video/carminefb.c: improve error handling

Author: Julia Lawall <julia@diku.dk> This code had an error handling goto to the wrong place, a misplaced release_mem_region, and a duplicated release_mem_region. The semantic match that finds the double release_mem_region is as follows: (http://coccinelle.lip6.fr/) // @r@ expression e1,e2,e3; position p1,p2,p3; @@ release_mem_region@p1(e1, e2)@p3; … when != request_mem_region(e1,e2,e3) release_mem_region(e1, e2)@p2; @@ expression e

[SCSI] gdth: Add missing call to gdth_ioctl_free

Author: Julia Lawall <julia@diku.dk> Add missing call to gdth_ioctl_free before aborting. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression buf,ha,len,addr,E; @@ buf = gdth_ioctl_alloc(ha, len, FALSE, &addr) … when != false buf != NULL when != true buf == NULL when != \(E = buf\|buf = E\) when != …

Lire la suite