Message ID | 20170522183015.GA22310@embeddedgus (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Mon, May 22, 2017 at 01:30:15PM -0500, Gustavo A. R. Silva wrote: > Add null check before dereferencing pointer sgid_attr.ndev > inside function rdma_vlan_dev_vlan_id(). > > Addresses-Coverity-ID: 1373979 > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> > --- > drivers/infiniband/hw/qedr/qedr_cm.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) + Ram, Ram, IB part of qedr driver doesn't exist in MAINTAINERS file. > > diff --git a/drivers/infiniband/hw/qedr/qedr_cm.c b/drivers/infiniband/hw/qedr/qedr_cm.c > index 3d7705c..d86dbe8 100644 > --- a/drivers/infiniband/hw/qedr/qedr_cm.c > +++ b/drivers/infiniband/hw/qedr/qedr_cm.c > @@ -270,11 +270,13 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev, > return rc; > } > > - vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); > - if (vlan_id < VLAN_CFI_MASK) > - has_vlan = true; > - if (sgid_attr.ndev) > + if (sgid_attr.ndev) { > + vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); > + if (vlan_id < VLAN_CFI_MASK) > + has_vlan = true; > + > dev_put(sgid_attr.ndev); > + } I do agree that it is better than kernel panic trying to access NULL pointer, but I'm not sure that retaining default vlan_id = 0 is correct solution here. > > if (!memcmp(&sgid, &zgid, sizeof(sgid))) { > DP_ERR(dev, "gsi post send: GID not found GID index %d\n", > -- > 2.5.0 >
> + Ram, > > Ram, IB part of qedr driver doesn't exist in MAINTAINERS file. > Weird. I'll fix it. Thanks, Ram -- 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
> Add null check before dereferencing pointer sgid_attr.ndev > inside function rdma_vlan_dev_vlan_id(). > > Addresses-Coverity-ID: 1373979 > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> > --- > drivers/infiniband/hw/qedr/qedr_cm.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/infiniband/hw/qedr/qedr_cm.c b/drivers/infiniband/hw/qedr/qedr_cm.c > index 3d7705c..d86dbe8 100644 > --- a/drivers/infiniband/hw/qedr/qedr_cm.c > +++ b/drivers/infiniband/hw/qedr/qedr_cm.c > @@ -270,11 +270,13 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev, > return rc; > } > > - vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); > - if (vlan_id < VLAN_CFI_MASK) > - has_vlan = true; > - if (sgid_attr.ndev) > + if (sgid_attr.ndev) { > + vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); > + if (vlan_id < VLAN_CFI_MASK) > + has_vlan = true; > + > dev_put(sgid_attr.ndev); > + } > > if (!memcmp(&sgid, &zgid, sizeof(sgid))) { > DP_ERR(dev, "gsi post send: GID not found GID index %d\n", > -- > 2.5.0 > > -- > 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 Thanks. Acked-by: Ram Amrani <Ram.Amrani@cavium.com> -- 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
On Mon, 2017-05-22 at 13:30 -0500, Gustavo A. R. Silva wrote: > Add null check before dereferencing pointer sgid_attr.ndev > inside function rdma_vlan_dev_vlan_id(). > > Addresses-Coverity-ID: 1373979 > Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> > --- Thanks, applied.
diff --git a/drivers/infiniband/hw/qedr/qedr_cm.c b/drivers/infiniband/hw/qedr/qedr_cm.c index 3d7705c..d86dbe8 100644 --- a/drivers/infiniband/hw/qedr/qedr_cm.c +++ b/drivers/infiniband/hw/qedr/qedr_cm.c @@ -270,11 +270,13 @@ static inline int qedr_gsi_build_header(struct qedr_dev *dev, return rc; } - vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); - if (vlan_id < VLAN_CFI_MASK) - has_vlan = true; - if (sgid_attr.ndev) + if (sgid_attr.ndev) { + vlan_id = rdma_vlan_dev_vlan_id(sgid_attr.ndev); + if (vlan_id < VLAN_CFI_MASK) + has_vlan = true; + dev_put(sgid_attr.ndev); + } if (!memcmp(&sgid, &zgid, sizeof(sgid))) { DP_ERR(dev, "gsi post send: GID not found GID index %d\n",
Add null check before dereferencing pointer sgid_attr.ndev inside function rdma_vlan_dev_vlan_id(). Addresses-Coverity-ID: 1373979 Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> --- drivers/infiniband/hw/qedr/qedr_cm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)