Category: Coccinelle

drivers/mtd/maps: 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 …

Continue reading

drivers/isdn/hardware/mISDN: Use GFP_ATOMIC when a lock is held

Author: Julia Lawall <julia@diku.dk> The function inittiger is only called from nj_init_card, where a 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_irqrestore when any GFP_KERNEL@p … when any } @locked@ identifier gfp.fn; @@ spin_lock_irqsave(…) … …

Continue reading

staging: Use GFP_ATOMIC when a lock is held

Author: Julia Lawall <julia@diku.dk> In each case, the containing function is only called from one place, where a spin 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 … when any } @locked@ …

Continue reading

[SCSI] dpt_i2o: Use GFP_ATOMIC when a lock is held

Author: Julia Lawall <julia@diku.dk> The function adpt_i2o_post_wait is called from several places, in some of which, such as adpt_abort, a lock may be held. The functions adpt_i2o_reparse_lct and adpt_i2o_lct_get are called from several places, including adpt_rescan where a lock may be held. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @gfp …

Continue reading

mfd: kzalloc doesn’t return ERR_PTR

Author: Julia Lawall <julia@diku.dk> Use !x rather than IS_ERR(x) to test the result of kzalloc. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,E; @@ x = \(kmalloc\|kzalloc\|kcalloc\)(…) … when != x = E – IS_ERR(x) + !x // Signed-off-by: Julia Lawall Signed-off-by: Samuel Ortiz — drivers/mfd/abx500-core.c | 2 …

Continue reading

drivers/net: Eliminate a NULL pointer dereference

Author: Julia Lawall <julia@diku.dk> At the point of the print, dev is NULL. 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 && …) || …) { … when != if (…) S1 else S2 …

Continue reading

drivers/net/hamradio: Eliminate a NULL pointer dereference

Author: Julia Lawall <julia@diku.dk> At the point of the print, dev is NULL. 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 && …) || …) { … when != if (…) S1 else S2 …

Continue reading

drivers/platform/x86: Eliminate a NULL pointer dereference

Author: Julia Lawall <julia@diku.dk> Give different error messages if device_enum is NULL or if its type field has the wrong value. 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 && …) || …) { …

Continue reading

USB: host: Eliminate NULL dereference

Author: Julia Lawall <julia@diku.dk> The test above allows std to be NULL, so check that std is not NULL before doing the dereference. 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 && …) || …

Continue reading

Staging: Eliminate a NULL pointer dereference

Author: Julia Lawall <julia@diku.dk> Eliminate a NULL or near NULL pointer dereference. 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 && …) || …) { … when != if (…) S1 else S2 when …

Continue reading