mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Shved <shved@ispras.ru>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Pavel Shved <shved@ispras.ru>,
	linux-kernel@vger.kernel.org, ldv-project@ispras.ru
Subject: [PATCH] synclink_gt: add module_put on error path in hdlcdev_open()
Date: Fri, 17 Jun 2011 20:25:13 +0400	[thread overview]
Message-ID: <1308327913-23220-4-git-send-email-shved@ispras.ru> (raw)
In-Reply-To: <1308327913-23220-1-git-send-email-shved@ispras.ru>

hdlcdev_open() calls try_module_get, and does not put the module when
other functions subsequently called fail.

The patch adds an exit point in hdlcdev_open() that calls module_put()
after such errors.

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

Signed-off-by: Pavel Shved <shved@ispras.ru>
---
 drivers/tty/synclink_gt.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
index 18b48cd..e1e89a0 100644
--- a/drivers/tty/synclink_gt.c
+++ b/drivers/tty/synclink_gt.c
@@ -1542,14 +1542,15 @@ static int hdlcdev_open(struct net_device *dev)
 
 	/* generic HDLC layer open processing */
 	if ((rc = hdlc_open(dev)))
-		return rc;
+		goto do_put;
 
 	/* arbitrate between network and tty opens */
 	spin_lock_irqsave(&info->netlock, flags);
 	if (info->port.count != 0 || info->netcount != 0) {
 		DBGINFO(("%s hdlc_open busy\n", dev->name));
 		spin_unlock_irqrestore(&info->netlock, flags);
-		return -EBUSY;
+		rc = -EBUSY;
+		goto do_put;
 	}
 	info->netcount=1;
 	spin_unlock_irqrestore(&info->netlock, flags);
@@ -1559,7 +1560,7 @@ static int hdlcdev_open(struct net_device *dev)
 		spin_lock_irqsave(&info->netlock, flags);
 		info->netcount=0;
 		spin_unlock_irqrestore(&info->netlock, flags);
-		return rc;
+		goto do_put;
 	}
 
 	/* assert DTR and RTS, apply hardware settings */
@@ -1579,6 +1580,10 @@ static int hdlcdev_open(struct net_device *dev)
 	else
 		netif_carrier_off(dev);
 	return 0;
+
+do_put:
+	module_put(THIS_MODULE);
+	return rc;
 }
 
 /**
-- 
1.7.0.2


  parent 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 ` [PATCH] gigaset: call module_put before restart of if_open() Pavel Shved
2011-06-17 19:28   ` 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 ` Pavel Shved [this message]
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-4-git-send-email-shved@ispras.ru \
    --to=shved@ispras.ru \
    --cc=gregkh@suse.de \
    --cc=ldv-project@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®