Catégorie : Coccinelle

i2c-dev: Use memdup_user

Author: Julia Lawall <julia@diku.dk> Use memdup_user when user data is immediately copied into the allocated region. Note that in the second case, the ++i is no longer necessary, as the last value is already freed if needed by the call to memdup_user. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ …

Lire la suite

fs/ecryptfs: Return -ENOMEM on memory allocation failure

Author: Julia Lawall <julia@diku.dk> In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression ret; expression x,e1,e2,e3; @@ ret = 0 … when != ret = e1 …

Lire la suite

[SCSI] drivers/message/fusion: Return -ENOMEM on memory allocation failure

Author: Julia Lawall <julia@diku.dk> In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression ret; expression x,e1,e2,e3; @@ ret = 0 … when != ret = e1 …

Lire la suite

USB: gadget: Return -ENOMEM on memory allocation failure

Author: Julia Lawall <julia@diku.dk> In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression ret; expression x,e1,e2,e3; @@ ret = 0 … when != ret = e1 …

Lire la suite

drivers/char/n_gsm.c: add missing spin_unlock_irqrestore

Author: Julia Lawall <julia@diku.dk> Add a spin_unlock_irqrestore missing on the error path. Converting the return to break leads to the spin_unlock_irqrestore at the end of the function. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E1; @@ * spin_lock_irqsave(E1,…); * spin_unlock_irqrestore(E1,…); // Signed-off-by: Julia Lawall Cc: Greg Kroah-Hartman Cc: …

Lire la suite

drivers/message/i2o/exec-osm.c: add missing mutex_unlock

Author: Julia Lawall <julia@diku.dk> Add a mutex_unlock missing on the error path. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E1; @@ * mutex_lock(E1,…); * mutex_unlock(E1,…); // Signed-off-by: Julia Lawall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds — drivers/message/i2o/exec-osm.c | 8 ++++++– 1 file changed, 6 insertions(+), 2 deletions(-)   …

Lire la suite

drivers/scsi: 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) || …) { } – …

Lire la suite

drivers/scsi/aic94xx/aic94xx_init.c: correct the size argument to kmalloc

Author: Julia Lawall <julia@diku.dk> In each case, the destination of the allocation has type struct **, so the elements of the array should have pointer type, not structure type. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @disable sizeof_type_expr@ type T; T **x; @@ x = // Signed-off-by: Julia Lawall Cc: …

Lire la suite

drivers/message: move dereference after NULL test

Author: Julia Lawall <julia@diku.dk> If the NULL test on dev->i2o_dev or i2o_dev is needed, then the dereference should be after the NULL test. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // @match exists@ expression x, E; identifier fld; @@ * x->fld … when != \(x = E\|&x\) …

Lire la suite

drivers/scsi: remove unnecessary NULL test

Author: Julia Lawall <julia@diku.dk> At the point where cmnd is initialized, it is tested for NULL, so it doesn’t have to be tested again here. A simplified version of the semantic match that detects this problem is as follows (http://coccinelle.lip6.fr/): // @match exists@ expression x, E; identifier fld; @@ * x->fld … when != \(x …

Lire la suite