diff options
author | Julia Lawall <julia@diku.dk> | 2011-03-23 19:42:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-03-23 22:46:39 -0400 |
commit | d9d691f584bd012d235c35279c043a2ccd23d7d7 (patch) | |
tree | 9094c048d6df951f14e2fb1cc790366791fdd7d5 /drivers/tty | |
parent | 73210a135b9dd53ba59beb4ced5a55633ae65b2f (diff) |
drivers/tty/bfin_jtag_comm.c: avoid calling put_tty_driver on NULL
put_tty_driver calls tty_driver_kref_put on its argument, and then
tty_driver_kref_put calls kref_put on the address of a field of this
argument. kref_put checks for NULL, but in this case the field is likely
to have some offset and so the result of taking its address will not be
NULL. Labels are added to be able to skip over the call to put_tty_driver
when the argument will be NULL.
The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression *x;
@@
*if (x == NULL)
{ ...
* put_tty_driver(x);
...
return ...;
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Torben Hohn <torbenh@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/bfin_jtag_comm.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/tty/bfin_jtag_comm.c b/drivers/tty/bfin_jtag_comm.c index 16402445f2b2..03c285bb2f18 100644 --- a/drivers/tty/bfin_jtag_comm.c +++ b/drivers/tty/bfin_jtag_comm.c | |||
@@ -251,11 +251,11 @@ static int __init bfin_jc_init(void) | |||
251 | bfin_jc_write_buf.head = bfin_jc_write_buf.tail = 0; | 251 | bfin_jc_write_buf.head = bfin_jc_write_buf.tail = 0; |
252 | bfin_jc_write_buf.buf = kmalloc(CIRC_SIZE, GFP_KERNEL); | 252 | bfin_jc_write_buf.buf = kmalloc(CIRC_SIZE, GFP_KERNEL); |
253 | if (!bfin_jc_write_buf.buf) | 253 | if (!bfin_jc_write_buf.buf) |
254 | goto err; | 254 | goto err_buf; |
255 | 255 | ||
256 | bfin_jc_driver = alloc_tty_driver(1); | 256 | bfin_jc_driver = alloc_tty_driver(1); |
257 | if (!bfin_jc_driver) | 257 | if (!bfin_jc_driver) |
258 | goto err; | 258 | goto err_driver; |
259 | 259 | ||
260 | bfin_jc_driver->owner = THIS_MODULE; | 260 | bfin_jc_driver->owner = THIS_MODULE; |
261 | bfin_jc_driver->driver_name = DRV_NAME; | 261 | bfin_jc_driver->driver_name = DRV_NAME; |
@@ -275,7 +275,9 @@ static int __init bfin_jc_init(void) | |||
275 | 275 | ||
276 | err: | 276 | err: |
277 | put_tty_driver(bfin_jc_driver); | 277 | put_tty_driver(bfin_jc_driver); |
278 | err_driver: | ||
278 | kfree(bfin_jc_write_buf.buf); | 279 | kfree(bfin_jc_write_buf.buf); |
280 | err_buf: | ||
279 | kthread_stop(bfin_jc_kthread); | 281 | kthread_stop(bfin_jc_kthread); |
280 | return ret; | 282 | return ret; |
281 | } | 283 | } |