macsec: missing dev_put() on error in macsec_newlink()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 21 Mar 2018 08:09:01 +0000 (11:09 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Mar 2018 18:30:36 +0000 (14:30 -0400)
We moved the dev_hold(real_dev); call earlier in the function but forgot
to update the error paths.

Fixes: 0759e552bce7 ("macsec: fix negative refcnt on parent link")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macsec.c

index 7de88b33d5b96d7f18a5f7c242a54c935b587086..9cbb0c8a896aff9d192850ad15734dc2872c0dfb 100644 (file)
@@ -3277,7 +3277,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 
        err = netdev_upper_dev_link(real_dev, dev, extack);
        if (err < 0)
-               goto unregister;
+               goto put_dev;
 
        /* need to be already registered so that ->init has run and
         * the MAC addr is set
@@ -3316,7 +3316,8 @@ del_dev:
        macsec_del_dev(macsec);
 unlink:
        netdev_upper_dev_unlink(real_dev, dev);
-unregister:
+put_dev:
+       dev_put(real_dev);
        unregister_netdevice(dev);
        return err;
 }