Author: Julia Lawall <julia@diku.dk> Check that the result of kmalloc/kzalloc is not NULL before dereferencing it. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression *x; identifier f; constant char *C; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(…); … when != x == NULL when != x != NULL when != (x || …
Category: Linux
Aug 07 2009
drivers/ata: use resource_size
Author: Julia Lawall <julia@diku.dk> Use the function resource_size, which reduces the chance of introducing off-by-one errors in calculating the resource size. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ struct resource *res; @@ – (res->end – res->start) + 1 + resource_size(res) // Signed-off-by: Julia Lawall Cc: Jeff Garzik Signed-off-by: Andrew …
Aug 07 2009
drivers/mmc: correct error-handling code
Author: Julia Lawall <julia@diku.dk> sdhci_alloc_host returns an ERR_PTR value in an error case instead of NULL. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @match exists@ expression x, E; statement S1, S2; @@ x = sdhci_alloc_host(…) … when != x = E ( * if (x == …
Aug 07 2009
drivers/w1/masters/omap_hdq.c: fix missing mutex unlock
Author: Stoyan Gaydarov <sgayda2@uiuc.edu> This was found using a semantic patch, more info can be found at: http://www.emn.fr/x-info/coccinelle/ Signed-off-by: Stoyan Gaydarov Acked-by: Evgeniy Polyakov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds — drivers/w1/masters/omap_hdq.c | 1 + 1 file changed, 1 insertion(+) diff –git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index a7e3b70..0d92969 100644 — a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c @@ -687,6 +687,7 …
Aug 07 2009
Bluetooth: Add missing kmalloc NULL tests to Marvell driver
Author: Julia Lawall <julia@diku.dk> Check that the result of kmalloc is not NULL before dereferencing it. The patch also replaces kmalloc + memset by kzalloc. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression *x; identifier f; constant char *C; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(…); … when != x == NULL …
Aug 06 2009
net/rds: Use AF_INET for sin_family field
Author: Julia Lawall <julia@diku.dk> Elsewhere the sin_family field holds a value with a name of the form AF_…, so it seems reasonable to do so here as well. Also the values of PF_INET and AF_INET are the same. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ struct sockaddr_in sip; @@ …
Aug 05 2009
security/smack: Use AF_INET for sin_family field
Author: Julia Lawall <julia@diku.dk> Elsewhere the sin_family field holds a value with a name of the form AF_…, so it seems reasonable to do so here as well. Also the values of PF_INET and AF_INET are the same. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ struct sockaddr_in sip; @@ …
Aug 03 2009
ARM: 5635/1: Use DIV_ROUND_CLOSEST
Author: Julia Lawall <julia@diku.dk> The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @haskernel@ @@ @depends on haskernel@ expression x,__divisor; @@ – (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // Signed-off-by: Julia Lawall Acked-by: H …
Aug 03 2009
drivers/net/wireless/iwlwifi: introduce missing kfree
Author: Julia Lawall <julia@diku.dk> Move orthogonal error handling code up before a kzalloc, so that it doesn’t have to 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 = …
Aug 03 2009
drivers/ide/ide-cd.c: Use DIV_ROUND_CLOSEST
Author: Julia Lawall <julia@diku.dk> The kernel.h macro DIV_ROUND_CLOSEST performs the computation (x + d/2)/d but is perhaps more readable. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @haskernel@ @@ #include @depends on haskernel@ expression x,__divisor; @@ – (((x) + ((__divisor) / 2)) / (__divisor)) + DIV_ROUND_CLOSEST(x,__divisor) // Signed-off-by: Julia Lawall Acked-by: …