lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 17 Jun 2011 20:25:13 +0400
From:	Pavel Shved <shved@...ras.ru>
To:	Greg Kroah-Hartman <gregkh@...e.de>
Cc:	Pavel Shved <shved@...ras.ru>, linux-kernel@...r.kernel.org,
	ldv-project@...ras.ru
Subject: [PATCH] synclink_gt: add module_put on error path in hdlcdev_open()

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@...ras.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ