public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Shved <shved@ispras.ru>
To: Hansjoerg Lipp <hjlipp@web.de> (maintainer:GIGASET ISDN DRIVERS)
Cc: Pavel Shved <shved@ispras.ru>,
	Tilman Schmidt <tilman@imap.cc> (maintainer:GIGASET ISDN DRIVERS),
	Karsten Keil <isdn@linux-pingi.de> (maintainer:ISDN SUBSYSTEM),
	gigaset307x-common@lists.sourceforge.net (open list:GIGASET ISDN
	DRIVERS), netdev@vger.kernel.org (open list:ISDN SUBSYSTEM),
	linux-kernel@vger.kernel.org (open list),
	ldv-project@ispras.ru
Subject: [PATCH] gigaset: call module_put before restart of if_open()
Date: Fri, 17 Jun 2011 20:25:11 +0400	[thread overview]
Message-ID: <1308327913-23220-2-git-send-email-shved@ispras.ru> (raw)
In-Reply-To: <1308327913-23220-1-git-send-email-shved@ispras.ru>

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>
---
 drivers/isdn/gigaset/interface.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
index 59de638..e35058b 100644
--- a/drivers/isdn/gigaset/interface.c
+++ b/drivers/isdn/gigaset/interface.c
@@ -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;
-- 
1.7.0.2


  reply	other threads:[~2011-06-17 16:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-17 16:25 [PATCH] farsync: add module_put to error path in fst_open() Pavel Shved
2011-06-17 16:25 ` Pavel Shved [this message]
2011-06-17 19:28   ` [PATCH] gigaset: call module_put before restart of if_open() David Miller
2011-06-17 16:25 ` [PATCH] hecubafb: add module_put on error path in hecubafb_probe() Pavel Shved
2011-06-24  8:02   ` Paul Mundt
2011-06-17 16:25 ` [PATCH] synclink_gt: add module_put on error path in hdlcdev_open() Pavel Shved
2011-06-17 19:28 ` [PATCH] farsync: add module_put to error path in fst_open() David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1308327913-23220-2-git-send-email-shved@ispras.ru \
    --to=shved@ispras.ru \
    --cc=gigaset307x-common@lists.sourceforge.net \
    --cc=hjlipp@web.de \
    --cc=isdn@linux-pingi.de \
    --cc=ldv-project@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tilman@imap.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox