netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] farsync: add module_put to error path in fst_open()
@ 2011-06-17 16:25 Pavel Shved
  2011-06-17 16:25 ` [PATCH] gigaset: call module_put before restart of if_open() Pavel Shved
  2011-06-17 19:28 ` [PATCH] farsync: add module_put to error path in fst_open() David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Pavel Shved @ 2011-06-17 16:25 UTC (permalink / raw)
  To: Kevin Curtis; +Cc: Pavel Shved, netdev, linux-kernel, ldv-project

The fst_open() function, after a successful try_module_get() may return
an error code if hdlc_open() returns it.  However, it does not put the
module on this error path.

This patch adds the necessary module_put() call.

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

Signed-off-by: Pavel Shved <shved@ispras.ru>
---
 drivers/net/wan/farsync.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index e050bd6..777d1a4 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -2203,8 +2203,10 @@ fst_open(struct net_device *dev)
 
 	if (port->mode != FST_RAW) {
 		err = hdlc_open(dev);
-		if (err)
+		if (err) {
+			module_put(THIS_MODULE);
 			return err;
+		}
 	}
 
 	fst_openport(port);
-- 
1.7.0.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] gigaset: call module_put before restart of if_open()
  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
  2011-06-17 19:28   ` David Miller
  2011-06-17 19:28 ` [PATCH] farsync: add module_put to error path in fst_open() David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Pavel Shved @ 2011-06-17 16:25 UTC (permalink / raw)
  To: Hansjoerg Lipp
  Cc: Pavel Shved, Tilman Schmidt, Karsten Keil,
	open list:GIGASET ISDN DRIVERS, open list:ISDN SUBSYSTEM,
	open list, ldv-project

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gigaset: call module_put before restart of if_open()
  2011-06-17 16:25 ` [PATCH] gigaset: call module_put before restart of if_open() Pavel Shved
@ 2011-06-17 19:28   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-06-17 19:28 UTC (permalink / raw)
  To: shved
  Cc: hjlipp, tilman, isdn, gigaset307x-common, netdev, linux-kernel,
	ldv-project

From: Pavel Shved <shved@ispras.ru>
Date: Fri, 17 Jun 2011 20:25:11 +0400

> 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>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] farsync: add module_put to error path in fst_open()
  2011-06-17 16:25 [PATCH] farsync: add module_put to error path in fst_open() Pavel Shved
  2011-06-17 16:25 ` [PATCH] gigaset: call module_put before restart of if_open() Pavel Shved
@ 2011-06-17 19:28 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-06-17 19:28 UTC (permalink / raw)
  To: shved; +Cc: kevin.curtis, netdev, linux-kernel, ldv-project

From: Pavel Shved <shved@ispras.ru>
Date: Fri, 17 Jun 2011 20:25:10 +0400

> The fst_open() function, after a successful try_module_get() may return
> an error code if hdlc_open() returns it.  However, it does not put the
> module on this error path.
> 
> This patch adds the necessary module_put() call.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Pavel Shved <shved@ispras.ru>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-17 19:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-17 16:25 [PATCH] farsync: add module_put to error path in fst_open() Pavel Shved
2011-06-17 16:25 ` [PATCH] gigaset: call module_put before restart of if_open() Pavel Shved
2011-06-17 19:28   ` David Miller
2011-06-17 19:28 ` [PATCH] farsync: add module_put to error path in fst_open() David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).