Message ID | 950a0611-4aad-9b85-8d18-3dff54db2820@sandisk.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Mon, Nov 21, 2016 at 10:22:17AM -0800, Bart Van Assche wrote: > This patch avoids that Coverity complains about not checking the > ib_find_pkey() return value. > > Fixes: commit 547af76521b3 ("IB/multicast: Report errors on multicast groups if P_key changes") > Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> > Cc: Sean Hefty <sean.hefty@intel.com> > Cc: <stable@vger.kernel.org> > --- > drivers/infiniband/core/multicast.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c > index e51b739..322cb67 100644 > --- a/drivers/infiniband/core/multicast.c > +++ b/drivers/infiniband/core/multicast.c > @@ -518,8 +518,11 @@ static void join_handler(int status, struct ib_sa_mcmember_rec *rec, > process_join_error(group, status); > else { > int mgids_changed, is_mgid0; > - ib_find_pkey(group->port->dev->device, group->port->port_num, > - be16_to_cpu(rec->pkey), &pkey_index); > + > + if (ib_find_pkey(group->port->dev->device, > + group->port->port_num, be16_to_cpu(rec->pkey), > + &pkey_index)) > + pkey_index = MCAST_INVALID_PKEY_INDEX; The coverity warning is valid, ib_find_pkey() can return ENOMEM (ib_find_pkey()->ib_query_pkey()->(device->query_pkey())->mlx5_ib_query_pkey()->mlx5_query_mad_ifc_pkey()/mlx5_query_hca_vport_pkey()) I'm not sure that the error handling proposed is enough, pkey_index is initialized to MCAST_INVALID_PKEY_INDEX at the beginning of function and in case of error it preserves its value. Don't you need to update process_group_error() function? It has code flows with ib_find_pkey() without checking return value, which can be anything too. Thanks > > spin_lock_irq(&group->port->lock); > if (group->state == MCAST_BUSY && > -- > 2.10.2 > > -- > 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 11/21/2016 11:11 PM, Leon Romanovsky wrote: > Don't you need to update process_group_error() function? It has code > flows with ib_find_pkey() without checking return value, which can be > anything too. Hello Leon, I'll leave that to someone who is familiar with the multicast code. Bart. -- 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/drivers/infiniband/core/multicast.c b/drivers/infiniband/core/multicast.c index e51b739..322cb67 100644 --- a/drivers/infiniband/core/multicast.c +++ b/drivers/infiniband/core/multicast.c @@ -518,8 +518,11 @@ static void join_handler(int status, struct ib_sa_mcmember_rec *rec, process_join_error(group, status); else { int mgids_changed, is_mgid0; - ib_find_pkey(group->port->dev->device, group->port->port_num, - be16_to_cpu(rec->pkey), &pkey_index); + + if (ib_find_pkey(group->port->dev->device, + group->port->port_num, be16_to_cpu(rec->pkey), + &pkey_index)) + pkey_index = MCAST_INVALID_PKEY_INDEX; spin_lock_irq(&group->port->lock); if (group->state == MCAST_BUSY &&
This patch avoids that Coverity complains about not checking the ib_find_pkey() return value. Fixes: commit 547af76521b3 ("IB/multicast: Report errors on multicast groups if P_key changes") Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: <stable@vger.kernel.org> --- drivers/infiniband/core/multicast.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)