net: wan: sbni: fix device usage count
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Thu, 3 Sep 2015 06:00:30 +0000 (11:30 +0530)
committerDavid S. Miller <davem@davemloft.net>
Sun, 6 Sep 2015 00:32:53 +0000 (17:32 -0700)
dev_get_by_name() will increment the usage count if the matching device
is found. But we were not decrementing the count if we have got the
device and the device is non-active.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wan/sbni.c

index 758c4ba1e97c91389ad6e5d1e6cda37f0dae26fa..8fef8d83436ddef9682df26e8ed2af6f2ae13377 100644 (file)
@@ -1358,6 +1358,8 @@ sbni_ioctl( struct net_device  *dev,  struct ifreq  *ifr,  int  cmd )
                if( !slave_dev  ||  !(slave_dev->flags & IFF_UP) ) {
                        netdev_err(dev, "trying to enslave non-active device %s\n",
                                   slave_name);
+                       if (slave_dev)
+                               dev_put(slave_dev);
                        return  -EPERM;
                }