Message ID | 20230406042549.507328-1-saravanan.vajravel@broadcom.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v2,for-rc] RDMA/srpt: Add a check for valid 'mad_agent' pointer | expand |
On 4/5/23 21:25, Saravanan Vajravel wrote: > + if (IS_ERR(mad_agent)) { > pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n", > dev_name(&sport->sdev->device->dev), sport->port, > - PTR_ERR(sport->mad_agent)); > + PTR_ERR(mad_agent)); > sport->mad_agent = NULL; > memset(&port_modify, 0, sizeof(port_modify)); > port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; > ib_modify_port(sport->sdev->device, sport->port, 0, > &port_modify); > - > + } else { > + sport->mad_agent = mad_agent; > } > } > With an early return the 'else' clause wouldn't have been necessary. Anyway: Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Wed, 05 Apr 2023 21:25:49 -0700, Saravanan Vajravel wrote: > When unregistering MAD agent, srpt module has a non-null check > for 'mad_agent' pointer before invoking ib_unregister_mad_agent(). > This check can pass if 'mad_agent' variable holds an error value. > The 'mad_agent' can have an error value for a short window when > srpt_add_one() and srpt_remove_one() is executed simultaneously. > > In srpt module, added a valid pointer check for 'sport->mad_agent' > before unregistering MAD agent. > > [...] Applied, thanks! [1/1] RDMA/srpt: Add a check for valid 'mad_agent' pointer https://git.kernel.org/rdma/rdma/c/eca5cd9474cd26 Best regards,
On Thu, Apr 06, 2023 at 10:08:18AM -0700, Bart Van Assche wrote: > On 4/5/23 21:25, Saravanan Vajravel wrote: > > + if (IS_ERR(mad_agent)) { > > pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n", > > dev_name(&sport->sdev->device->dev), sport->port, > > - PTR_ERR(sport->mad_agent)); > > + PTR_ERR(mad_agent)); > > sport->mad_agent = NULL; > > memset(&port_modify, 0, sizeof(port_modify)); > > port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; > > ib_modify_port(sport->sdev->device, sport->port, 0, > > &port_modify); > > - > > + } else { > > + sport->mad_agent = mad_agent; > > } > > } > > With an early return the 'else' clause wouldn't have been necessary. Anyway: > > Reviewed-by: Bart Van Assche <bvanassche@acm.org> Thanks, I fixed it locally and applied.
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 3c3fae738c3e..b4cb88563bb2 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -549,6 +549,7 @@ static int srpt_format_guid(char *buf, unsigned int size, const __be64 *guid) */ static int srpt_refresh_port(struct srpt_port *sport) { + struct ib_mad_agent *mad_agent; struct ib_mad_reg_req reg_req; struct ib_port_modify port_modify; struct ib_port_attr port_attr; @@ -593,23 +594,24 @@ static int srpt_refresh_port(struct srpt_port *sport) set_bit(IB_MGMT_METHOD_GET, reg_req.method_mask); set_bit(IB_MGMT_METHOD_SET, reg_req.method_mask); - sport->mad_agent = ib_register_mad_agent(sport->sdev->device, - sport->port, - IB_QPT_GSI, - ®_req, 0, - srpt_mad_send_handler, - srpt_mad_recv_handler, - sport, 0); - if (IS_ERR(sport->mad_agent)) { + mad_agent = ib_register_mad_agent(sport->sdev->device, + sport->port, + IB_QPT_GSI, + ®_req, 0, + srpt_mad_send_handler, + srpt_mad_recv_handler, + sport, 0); + if (IS_ERR(mad_agent)) { pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n", dev_name(&sport->sdev->device->dev), sport->port, - PTR_ERR(sport->mad_agent)); + PTR_ERR(mad_agent)); sport->mad_agent = NULL; memset(&port_modify, 0, sizeof(port_modify)); port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify); - + } else { + sport->mad_agent = mad_agent; } }