Catégorie : Linux

net/ax25: Use available error codes

Author: Julia Lawall <julia@diku.dk> Error codes are stored in err, but the return value is always 0. Return err 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 …

Lire la suite

llseek: automatically add .llseek fop

Author: Arnd Bergmann <arnd@arndb.de> All file_operations should get a .llseek operation so we can make nonseekable_open the default for future file operations without a .llseek pointer. The three cases that we can automatically detect are no_llseek, seq_lseek and default_llseek. For cases where we can we can automatically prove that the file offset is always ignored, …

Lire la suite

hwmon: (k8temp) Adjust confusing if indentation

Author: Julia Lawall <julia@diku.dk> Move the if(err) statement after the if into the if branch indicated by its indentation. The preceding if(err) test implies that err cannot be nonzero unless the if branch is taken. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r disable braces5@ position p1,p2; statement S1,S2; @@ …

Lire la suite

dm crypt: use kstrdup

Author: Julia Lawall <julia@diku.dk> Use kstrdup when the goal of an allocation is copy a string into the allocated region. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to; expression flag,E1,E2; statement S; @@ – to = kmalloc(strlen(from) + 1,flag); + to = kstrdup(from, flag); … when != \(from …

Lire la suite

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