Author: Julia Lawall <julia@diku.dk> The 1 element of the array is tested twice. Change the code so that the remaining 3 element of the array is tested instead of testing the 1 element a second time. The sematic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression E; @@ ( * E …
Aug 28 2010
drivers/net/atl1c: Remove double test
Author: Julia Lawall <julia@diku.dk> The nic_type field is compared to athr_l2c twice. The sematic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @expression@ expression E; @@ ( * E || … || E | * E && … && E ) // Signed-off-by: Julia Lawall Signed-off-by: David S. Miller — drivers/net/atl1c/atl1c_hw.c | 2 …
Aug 28 2010
net/ipv4: Eliminate kstrdup memory leak
Author: Julia Lawall <julia@diku.dk> The string clone is only used as a temporary copy of the argument val within the while loop, and so it should be freed before leaving the function. The call to strsep, however, modifies clone, so a pointer to the front of the string is kept in saved_clone, to make it …
Aug 27 2010
V4L/DVB: drivers/media/video/em28xx: Remove potential NULL dereference
Author: Julia Lawall <julia@diku.dk> If the NULL test is necessary, the initialization involving a dereference of the tested value should be moved after the NULL test. The sematic patch that fixes this problem is as follows: (http://coccinelle.lip6.fr/) // @@ type T; expression E; identifier i,fld; statement S; @@ – T i = E->fld; + T …
Aug 24 2010
net/netfilter/ipvs: Eliminate memory leak
Author: Julia Lawall <julia@diku.dk> __ip_vs_service_get and __ip_vs_svc_fwm_get increment a reference count, so that reference count should be decremented before leaving the function in an error case. A simplified version of the semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @r exists@ local idexpression x; expression E; identifier f1; iterator I; @@ x = __ip_vs_service_get(…); …
Aug 24 2010
drivers/net/irda: Eliminate memory leak
Author: Julia Lawall <julia@diku.dk> dev_alloc_skb allocates some memory, so that memory should be freed before leaving the function in an error case. Corrected some typos in a nearby comment as well. A simplified version of the semantic match that finds this problem is: (http://coccinelle.lip6.fr/) // @r exists@ local idexpression x; expression E; identifier f1; iterator …
Aug 23 2010
drivers/net: Remove address use from assignments of function pointers
Author: Joe Perches <joe@perches.com> “foo = &function” is more commonly written “foo = function” Done with coccinelle script: // @r@ identifier f; @@ f(…) { … } @@ identifier r.f; @@ – &f + f // drivers/net/tehuti.c used a function and struct with the same name, the function was renamed. Compile tested x86 only. Signed-off-by: …
Aug 23 2010
arch/mn10300/mm: eliminate NULL dereference
Author: Julia Lawall <julia@diku.dk> dev_name always dereferences its argument, so it should not be called if the argument is NULL. The function indeed later tests the argument for being NULL. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression dev,E; @@ *dev_name(dev) … when != dev = E ( *dev …
Aug 16 2010
V4L/DVB: drivers/media/video: Use available error codes
Author: Julia Lawall <julia@diku.dk> Error codes are stored in rc, but the return value is always 0. Return rc instead. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ local idexpression x; constant C; @@ if (…) { … x = -C … when != x ( return ; | return …
Aug 16 2010
drivers/net/wireless/wl12xx: Use available error codes
Author: Julia Lawall <julia@diku.dk> Error codes are stored in ret, but the return value is always 0. Return ret instead. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ local idexpression x; constant C; @@ if (…) { … x = -C … when != x ( return ; | return …