]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/smc: dev_put for netdev after usage of ib_query_gid()
authorUrsula Braun <ubraun@linux.vnet.ibm.com>
Wed, 11 Oct 2017 11:47:23 +0000 (13:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 12 Oct 2017 19:20:27 +0000 (12:20 -0700)
For RoCEs ib_query_gid() takes a reference count on the net_device.
This reference count must be decreased by the caller.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Reported-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Fixes: 0cfdd8f92cac ("smc: connection and link group creation")
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_core.c

index 20b66e79c5d6305dddf120f09249654732842c00..5f6a20084157b132ae86600d32e3de8222ce4082 100644 (file)
@@ -380,10 +380,14 @@ static int smc_link_determine_gid(struct smc_link_group *lgr)
                if (ib_query_gid(lnk->smcibdev->ibdev, lnk->ibport, i, &gid,
                                 &gattr))
                        continue;
-               if (gattr.ndev &&
-                   (vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id)) {
-                       lnk->gid = gid;
-                       return 0;
+               if (gattr.ndev) {
+                       if (is_vlan_dev(gattr.ndev) &&
+                           vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) {
+                               lnk->gid = gid;
+                               dev_put(gattr.ndev);
+                               return 0;
+                       }
+                       dev_put(gattr.ndev);
                }
        }
        return -ENODEV;