Message ID | 20230401063800.342432-1-saravanan.vajravel@broadcom.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [for-rc] RDMA/srpt: Add a check for valid 'mad_agent' pointer | expand |
On Fri, Mar 31, 2023 at 11:38:00PM -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. Don't fix it like this, don't store err values in global pointers. Jason
> On Fri, Mar 31, 2023 at 11:38:00PM -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. > Don't fix it like this, don't store err values in global pointers. Ok. I will re-work on the fix. -Saravanan
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 3c3fae738c3e..07c24182b085 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -634,7 +634,7 @@ static void srpt_unregister_mad_agent(struct srpt_device *sdev, int port_cnt) for (i = 1; i <= port_cnt; i++) { sport = &sdev->port[i - 1]; WARN_ON(sport->port != i); - if (sport->mad_agent) { + if (!IS_ERR_OR_NULL(sport->mad_agent)) { ib_modify_port(sdev->device, i, 0, &port_modify); ib_unregister_mad_agent(sport->mad_agent); sport->mad_agent = NULL;