Skip to content

Commit

Permalink
gigaset: call module_put before restart of if_open()
Browse files Browse the repository at this point in the history
if_open() calls try_module_get(), and after an attempt to lock a mutex
the if_open() function may return -ERESTARTSYS without
putting the module.  Then, when if_open() is executed again,
try_module_get() is called making the reference counter of THIS_MODULE
greater than one at successful exit from if_open().  The if_close()
function puts the module only once, and as a result it can't be
unloaded.

This patch adds module_put call before the return from if_open().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Pavel Shved <shved@ispras.ru>
Signed-off-by: David S. Miller <davem@conan.davemloft.net>
  • Loading branch information
Pavel Shved authored and David S. Miller committed Jun 17, 2011
1 parent d0fd64c commit 2f9381e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/isdn/gigaset/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ static int if_open(struct tty_struct *tty, struct file *filp)
if (!cs || !try_module_get(cs->driver->owner))
return -ENODEV;

if (mutex_lock_interruptible(&cs->mutex))
if (mutex_lock_interruptible(&cs->mutex)) {
module_put(cs->driver->owner);
return -ERESTARTSYS;
}
tty->driver_data = cs;

++cs->open_count;
Expand Down

0 comments on commit 2f9381e

Please sign in to comment.