Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: Correct use after free for t7l66xb

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 moved down below this label.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,e;
identifier f;
iterator I;
statement S;
@@

*kfree(x);
... when != &x
when != x = e
when != I(x,...) S
*x->f
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

authored by

Julia Lawall and committed by
Samuel Ortiz
0e820ab6 1ecc09e7

+1 -1
+1 -1
drivers/mfd/t7l66xb.c
··· 403 403 err_ioremap: 404 404 release_resource(&t7l66xb->rscr); 405 405 err_request_scr: 406 - kfree(t7l66xb); 407 406 clk_put(t7l66xb->clk48m); 408 407 err_clk48m_get: 409 408 clk_put(t7l66xb->clk32k); 410 409 err_clk32k_get: 411 410 err_noirq: 411 + kfree(t7l66xb); 412 412 return ret; 413 413 } 414 414