net/smc: adjust net_device refcount
authorUrsula Braun <ubraun@linux.vnet.ibm.com>
Thu, 21 Sep 2017 07:16:29 +0000 (09:16 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Sep 2017 22:31:02 +0000 (15:31 -0700)
smc_pnet_fill_entry() uses dev_get_by_name() adding a refcount to ndev.
The following smc_pnet_enter() has to reduce the refcount if the entry
to be added exists already in the pnet table.

Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_pnet.c

index 78f7af2..31f8453 100644 (file)
@@ -181,8 +181,10 @@ static int smc_pnet_enter(struct smc_pnetentry *new_pnetelem)
                             sizeof(new_pnetelem->ndev->name)) ||
                    smc_pnet_same_ibname(pnetelem,
                                         new_pnetelem->smcibdev->ibdev->name,
-                                        new_pnetelem->ib_port))
+                                        new_pnetelem->ib_port)) {
+                       dev_put(pnetelem->ndev);
                        goto found;
+               }
        }
        list_add_tail(&new_pnetelem->list, &smc_pnettable.pnetlist);
        rc = 0;