linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv()
@ 2021-04-08 11:31 Wang Wensheng
  2021-04-08 16:50 ` Bart Van Assche
  2021-04-12 18:47 ` Bart Van Assche
  0 siblings, 2 replies; 5+ messages in thread
From: Wang Wensheng @ 2021-04-08 11:31 UTC (permalink / raw)
  To: bvanassche, dledford, jgg, linux-rdma, target-devel, linux-kernel
  Cc: rui.xiang

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: db7683d7deb2 ("IB/srpt: Fix login-related race conditions")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index 98a393d..ea44780 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -2382,6 +2382,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
 		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
 			dev_name(&sdev->device->dev), port_num);
 		mutex_unlock(&sport->mutex);
+		ret = -EINVAL;
 		goto reject;
 	}
 
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv()
  2021-04-08 11:31 [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv() Wang Wensheng
@ 2021-04-08 16:50 ` Bart Van Assche
  2021-04-12 18:09   ` Jason Gunthorpe
  2021-04-12 18:47 ` Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2021-04-08 16:50 UTC (permalink / raw)
  To: Wang Wensheng, dledford, jgg, linux-rdma, target-devel, linux-kernel
  Cc: rui.xiang

On 4/8/21 4:31 AM, Wang Wensheng wrote:
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Fixes: db7683d7deb2 ("IB/srpt: Fix login-related race conditions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 98a393d..ea44780 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2382,6 +2382,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>  		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
>  			dev_name(&sdev->device->dev), port_num);
>  		mutex_unlock(&sport->mutex);
> +		ret = -EINVAL;
>  		goto reject;
>  	}

Please fix the Hulk Robot. The following code occurs three lines above
the modified code:

	ret = -EINVAL;

Thanks,

Bart.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv()
  2021-04-08 16:50 ` Bart Van Assche
@ 2021-04-12 18:09   ` Jason Gunthorpe
  2021-04-12 18:46     ` Bart Van Assche
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2021-04-12 18:09 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Wang Wensheng, dledford, linux-rdma, target-devel, linux-kernel,
	rui.xiang

On Thu, Apr 08, 2021 at 09:50:30AM -0700, Bart Van Assche wrote:
> On 4/8/21 4:31 AM, Wang Wensheng wrote:
> > Fix to return a negative error code from the error handling
> > case instead of 0, as done elsewhere in this function.
> > 
> > Fixes: db7683d7deb2 ("IB/srpt: Fix login-related race conditions")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
> >  drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> > index 98a393d..ea44780 100644
> > +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> > @@ -2382,6 +2382,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
> >  		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
> >  			dev_name(&sdev->device->dev), port_num);
> >  		mutex_unlock(&sport->mutex);
> > +		ret = -EINVAL;
> >  		goto reject;
> >  	}
> 
> Please fix the Hulk Robot. The following code occurs three lines above
> the modified code:
> 
> 	ret = -EINVAL;

That is a different if.

The patch looks correct to me, please check again:

	ret = srpt_create_ch_ib(ch);
	if (ret) {
	// Ret is proven to be 0
	
	[..]

	if (!sport->enabled) {
		rej->reason = cpu_to_be32(
				SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
			dev_name(&sdev->device->dev), port_num);
		goto reject; // Ret is 0

If there is an assignment to ret between those two blocks it is hidden..

Jason

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv()
  2021-04-12 18:09   ` Jason Gunthorpe
@ 2021-04-12 18:46     ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2021-04-12 18:46 UTC (permalink / raw)
  To: Jason Gunthorpe
  Cc: Wang Wensheng, dledford, linux-rdma, target-devel, linux-kernel,
	rui.xiang

On 4/12/21 11:09 AM, Jason Gunthorpe wrote:
> On Thu, Apr 08, 2021 at 09:50:30AM -0700, Bart Van Assche wrote:
>> On 4/8/21 4:31 AM, Wang Wensheng wrote:
>>> Fix to return a negative error code from the error handling
>>> case instead of 0, as done elsewhere in this function.
>>>
>>> Fixes: db7683d7deb2 ("IB/srpt: Fix login-related race conditions")
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
>>>  drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
>>> index 98a393d..ea44780 100644
>>> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
>>> @@ -2382,6 +2382,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>>>  		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
>>>  			dev_name(&sdev->device->dev), port_num);
>>>  		mutex_unlock(&sport->mutex);
>>> +		ret = -EINVAL;
>>>  		goto reject;
>>>  	}
>>
>> Please fix the Hulk Robot. The following code occurs three lines above
>> the modified code:
>>
>> 	ret = -EINVAL;
> 
> That is a different if.
> 
> The patch looks correct to me, please check again:
> 
> 	ret = srpt_create_ch_ib(ch);
> 	if (ret) {
> 	// Ret is proven to be 0
> 	
> 	[..]
> 
> 	if (!sport->enabled) {
> 		rej->reason = cpu_to_be32(
> 				SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES);
> 		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
> 			dev_name(&sdev->device->dev), port_num);
> 		goto reject; // Ret is 0
> 
> If there is an assignment to ret between those two blocks it is hidden..

Right, I was looking at another if-statement in the same function.

Bart.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv()
  2021-04-08 11:31 [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv() Wang Wensheng
  2021-04-08 16:50 ` Bart Van Assche
@ 2021-04-12 18:47 ` Bart Van Assche
  1 sibling, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2021-04-12 18:47 UTC (permalink / raw)
  To: Wang Wensheng, dledford, jgg, linux-rdma, target-devel, linux-kernel
  Cc: rui.xiang

On 4/8/21 4:31 AM, Wang Wensheng wrote:
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Fixes: db7683d7deb2 ("IB/srpt: Fix login-related race conditions")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Wensheng <wangwensheng4@huawei.com>
> ---
>  drivers/infiniband/ulp/srpt/ib_srpt.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 98a393d..ea44780 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -2382,6 +2382,7 @@ static int srpt_cm_req_recv(struct srpt_device *const sdev,
>  		pr_info("rejected SRP_LOGIN_REQ because target %s_%d is not enabled\n",
>  			dev_name(&sdev->device->dev), port_num);
>  		mutex_unlock(&sport->mutex);
> +		ret = -EINVAL;
>  		goto reject;
>  	}

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-12 18:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 11:31 [PATCH -next] RDMA/srpt: Fix error return code in srpt_cm_req_recv() Wang Wensheng
2021-04-08 16:50 ` Bart Van Assche
2021-04-12 18:09   ` Jason Gunthorpe
2021-04-12 18:46     ` Bart Van Assche
2021-04-12 18:47 ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).