Category: Linux

drivers/net/can: Correct NULL test

Author: Julia Lawall <julia@diku.dk> Test the just-allocated value for NULL rather than some other value. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,y; statement S; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(…); ( if ((x) == NULL) S | if ( – y + x == NULL) S ) // Signed-off-by: …

Continue reading

ext4: Eliminate potential double free on error path

Author: Julia Lawall <julia@diku.dk> b_entry_name and buffer are initially NULL, are initialized within a loop to the result of calling kmalloc, and are freed at the bottom of this loop. The loop contains gotos to cleanup, which also frees b_entry_name and buffer. Some of these gotos are before the reinitializations of b_entry_name and buffer. To …

Continue reading

V4L/DVB (13949): Move a dereference below a NULL test

Author: Julia Lawall <julia@diku.dk> If the NULL test is necessary, then the dereference should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; expression E; identifier i,fld; statement S; @@ – T i = E->fld; + T i; … when != E when …

Continue reading

mfd: Correct use after free for t7l66xb

Author: Julia Lawall <julia@diku.dk> The structure t7l66xb should not be freed before the subsequent references to its fields in the arguments to clk_put. Furthermore, this structure is allocated near the beginning of the function, and a goto to the label err_noirq appears after a successful allocation, so it would seem that the kfree should be …

Continue reading

V4L/DVB (13948): radio: Correct use after free

Author: Julia Lawall <julia@diku.dk> It is not clear how to share the unlock in the case where the structure containing the lock has to be freed. So the unlock is now duplicated, with one copy moved before the free. The unlock label furthermore is no longer useful and is thus deleted. A simplified version of …

Continue reading

drivers/dma: Correct use after free

Author: Julia Lawall <julia@diku.dk> Move the kfree after the iounmap that refers to the same structure. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,e; identifier f; iterator I; statement S; @@ *kfree(x); … when != &x when != x = e when != I(x,…) …

Continue reading

drivers/isdn: eliminate duplicated test

Author: Julia Lawall <julia@diku.dk> The code checked slot_rx twice. Check slot_tx by analogy with the bank case. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E; @@ ( *E && E | *E || E ) // Signed-off-by: Julia Lawall Cc: Karsten Keil Signed-off-by: Andrew Morton Signed-off-by: David S. …

Continue reading

drivers/dma: drop unnecesary memset

Author: Julia Lawall <julia@diku.dk> memset of 0 is not needed after kzalloc The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; statement S; @@ x = kzalloc(…); if (x == NULL) S … when != x -memset(x,0,…);// Signed-off-by: Julia Lawall Signed-off-by: Dan Williams — drivers/dma/dw_dmac.c | 2 — 1 …

Continue reading

ALSA: Use kzalloc for allocating only one thing

Author: Julia Lawall <julia@diku.dk> Use kzalloc rather than kcalloc(1,…) The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ @@ – kcalloc(1, + kzalloc( …) // Signed-off-by: Julia Lawall Signed-off-by: Takashi Iwai — sound/isa/msnd/msnd_midi.c | 2 +- sound/pci/hda/patch_realtek.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)   diff –git a/sound/isa/msnd/msnd_midi.c …

Continue reading

USB: isp1362: Use kzalloc for allocating only one thing

Author: Julia Lawall <julia@diku.dk> Use kzalloc rather than kcalloc(1,…) The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ @@ – kcalloc(1, + kzalloc( …) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman — drivers/usb/host/isp1362-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)   diff –git a/drivers/usb/host/isp1362-hcd.c b/drivers/usb/host/isp1362-hcd.c index 4297165..5596fc1 100644 …

Continue reading