Message ID | 20171010141351.87700-3-ubraun@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
> -----Original Message----- > From: Ursula Braun [mailto:ubraun@linux.vnet.ibm.com] > Sent: Tuesday, October 10, 2017 9:14 AM > To: davem@davemloft.net > Cc: netdev@vger.kernel.org; linux-rdma@vger.kernel.org; linux- > s390@vger.kernel.org; jwi@linux.vnet.ibm.com; schwidefsky@de.ibm.com; > heiko.carstens@de.ibm.com; raspl@linux.vnet.ibm.com; > ubraun@linux.vnet.ibm.com; Parav Pandit <parav@mellanox.com> > Subject: [PATCH net 2/2] net/smc: dev_put for netdev after usage of > ib_query_gid() > > 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> > --- > net/smc/smc_core.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index > 20b66e79c5d6..e93a31ec3cc2 100644 > --- a/net/smc/smc_core.c > +++ b/net/smc/smc_core.c > @@ -380,10 +380,13 @@ 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 (vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) { This needs to be changed to If (gattr.ndev) { if (is_vlan_dev(gattr.ndev)) && vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) { ... } Without this check, on vlan disabled kernel at compile time, kernel will crash on vlan_dev_vlan_id(). Please fix this part, rest code looks fine. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
> -----Original Message----- > > 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> > Also add 'Fixes' line that introduced this bug. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c index 20b66e79c5d6..e93a31ec3cc2 100644 --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -380,10 +380,13 @@ 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 (vlan_dev_vlan_id(gattr.ndev) == lgr->vlan_id) { + lnk->gid = gid; + dev_put(gattr.ndev); + return 0; + } + dev_put(gattr.ndev); } } return -ENODEV;
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> --- net/smc/smc_core.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)