Author: Julia Lawall <julia@diku.dk> Use kmemdup when some other buffer is immediately copied into the allocated region. A simplified version of the semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; statement S; @@ – to = \(kmalloc\|kzalloc\)(size,flag); + to = kmemdup(from,size,flag); if (to==NULL || …) S – memcpy(to, from, …
Jun 29 2010
V4L/DVB: drivers/media/video/pvrusb2: Add missing mutex_unlock
Author: Julia Lawall <julia@diku.dk> Add a mutex_unlock missing on the error path. In the other functions in the same file the locks and unlocks of this mutex appear to be balanced, so it would seem that the same should hold in this case. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // …
Jun 20 2010
V4L/DVB: drivers/media/dvb/frontends: remove duplicate structure field initialization
Author: Julia Lawall <julia@diku.dk> The read_status field is initialized twice to the same value. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier I, s, fld; position p0,p; expression E; @@ struct I s =@p0 { … .fld@p = E, …}; @s@ identifier I, s, r.fld; position r.p0,p; expression E; …
Jun 20 2010
arch/sh/mm: Eliminate a double lock
Author: Julia Lawall <julia@diku.dk> The function begins and ends with a read_lock. The latter is changed to a read_unlock. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @locked@ expression E1; position p; @@ read_lock(E1@p,…); @r exists@ expression x
Jun 20 2010
HID: eliminate a double lock in debug code
Author: Julia Lawall <julia@diku.dk> The path around the loop ends with the lock held, so the call to mutex_lock is moved before the beginning of the loop. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @locked@ expression E1; position p; @@ read_lock(E1@p,…); @r exists@ expression x
Jun 08 2010
[S390] arch/s390/kvm: Use GFP_ATOMIC when a lock is held
Author: Julia Lawall <julia@diku.dk> The containing function is called from several places. At one of them, in the function __sigp_stop, the spin lock &fi->lock is held. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @gfp exists@ identifier fn; position p; @@ fn(…) { … when != spin_unlock when any GFP_KERNEL@p … …
Jun 05 2010
arch/sparc/kernel: Eliminate what looks like a NULL pointer dereference
Author: Julia Lawall <julia@diku.dk> At the point of the test, action cannot be NULL, as it has been dereferenced in the code just above. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r exists@ expression E,E1; identifier f; statement S1,S2,S3; @@ if ((E == NULL && …) …
Jun 05 2010
drivers/ide: Use memdup_user
Author: Julia Lawall <julia@diku.dk> Use memdup_user when user data is immediately copied into the allocated region. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; position p; identifier l1,l2; @@ – to = \(kmalloc@p\|kzalloc@p\)(size,flag); + to = memdup_user(from,size); if ( – to==NULL + IS_ERR(to) || …) { } – …
Jun 01 2010
HID: roccat: introduce missing kfree
Author: Julia Lawall <julia@diku.dk> Error handling code following a kmalloc should free the allocated data. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(…); … if (x == NULL) S f1 …
Jun 01 2010
mfd: Fix davinci memory leak
Author: Julia Lawall <julia@diku.dk> Error handling code following a kmalloc should free the allocated data. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S; expression E; identifier f,f1,l; position p1,p2; expression *ptr != NULL; @@ x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(…); … if (x == NULL) S f1 …