diff options
author | Julia Lawall <julia@diku.dk> | 2008-10-13 05:31:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-13 12:51:37 -0400 |
commit | 2571cd6a8e07a13fd3ac77f5e2c5470966d6f9c9 (patch) | |
tree | 7e8790bb46b7decdb94d9efd2d6c0d76a1712668 /drivers | |
parent | 41ca73229809eb3d173e316d11d3943d49924209 (diff) |
drivers/char/hvc_console.c: adjust call to put_tty_driver
The call to put_tty_driver is out of place and is applied to the wrong
argument.
The function enclosing the patched code calls alloc_tty_driver and stores
the result in drv. Subsequently, there are two occurrences of error
handling code, one making a goto to put_tty and one making a goto to
stop_thread. At the point of the first one the assignment hvc_driver = drv
has not yet been executed, and from inspecting the rest of the file it
seems that hvc_driver would be NULL. Thus the current call to
put_tty_driver is useless, and one applied to drv is needed. The goto
stop_thread is in the error handling code for a call to
tty_register_driver, but the error cases in tty_register_driver do not free
its argument, so it should be done here. Thus, I have moved the put_tty
label after the stop_thread label, so that put_tty_driver is called in both
cases.
The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@r exists@
local idexpression x;
expression E,f;
position p1,p2,p3;
identifier l;
statement S;
@@
x = alloc_tty_driver@p1(...)
...
if (x == NULL) S
... when != E = x
when != put_tty_driver(x)
goto@p2 l;
... when != E = x
when != f(...,x,...)
when any
(
return \(0\|x\);
|
return@p3 ...;
)
@script:python@
p1 << r.p1;
p2 << r.p2;
p3 << r.p3;
@@
print "%s: call on line %s not freed or saved before return on line %s via line %s" % (p1[0].file,p1[0].line,p3[0].line,p2[0].line)
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/hvc_console.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index fd64137b1ab9..ec7aded0a2df 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -819,11 +819,11 @@ static int hvc_init(void) | |||
819 | hvc_driver = drv; | 819 | hvc_driver = drv; |
820 | return 0; | 820 | return 0; |
821 | 821 | ||
822 | put_tty: | ||
823 | put_tty_driver(hvc_driver); | ||
824 | stop_thread: | 822 | stop_thread: |
825 | kthread_stop(hvc_task); | 823 | kthread_stop(hvc_task); |
826 | hvc_task = NULL; | 824 | hvc_task = NULL; |
825 | put_tty: | ||
826 | put_tty_driver(drv); | ||
827 | out: | 827 | out: |
828 | return err; | 828 | return err; |
829 | } | 829 | } |