Messages in this thread Patch in this message | | | From | Pavel Shved <> | Subject | [PATCH] synclink_gt: add module_put on error path in hdlcdev_open() | Date | Fri, 17 Jun 2011 20:25:13 +0400 |
| |
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
| |