diff mbox series

9p/rdma: unmap receive dma buffer in rdma_request()

Message ID 20221220031223.3890143-1-shaozhengchao@huawei.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series 9p/rdma: unmap receive dma buffer in rdma_request() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Dec. 20, 2022, 3:12 a.m. UTC
When down_interruptible() failed in rdma_request(), receive dma buffer
is not unmapped. Add unmap action to error path.

Fixes: fc79d4b104f0 ("9p: rdma: RDMA Transport Support for 9P")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/9p/trans_rdma.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leon Romanovsky Dec. 28, 2022, 9:35 a.m. UTC | #1
On Tue, Dec 20, 2022 at 11:12:23AM +0800, Zhengchao Shao wrote:
> When down_interruptible() failed in rdma_request(), receive dma buffer
> is not unmapped. Add unmap action to error path.
> 
> Fixes: fc79d4b104f0 ("9p: rdma: RDMA Transport Support for 9P")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>  net/9p/trans_rdma.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
> index 83f9100d46bf..da83023fecbf 100644
> --- a/net/9p/trans_rdma.c
> +++ b/net/9p/trans_rdma.c
> @@ -499,6 +499,8 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
>  
>  	if (down_interruptible(&rdma->sq_sem)) {
>  		err = -EINTR;
> +		ib_dma_unmap_single(rdma->cm_id->device, c->busa,
> +				    c->req->tc.size, DMA_TO_DEVICE);
>  		goto send_error;
>  	}

It is not the only place where ib_dma_unmap_single() wasn't called.
Even at the same function if ib_post_send() fails, the unmap is not
called. Also post_recv() is missing call to ib_dma_unmap_single() too.

Thanks

>  
> -- 
> 2.34.1
>
shaozhengchao Jan. 4, 2023, 1:30 a.m. UTC | #2
On 2022/12/28 17:35, Leon Romanovsky wrote:
> On Tue, Dec 20, 2022 at 11:12:23AM +0800, Zhengchao Shao wrote:
>> When down_interruptible() failed in rdma_request(), receive dma buffer
>> is not unmapped. Add unmap action to error path.
>>
>> Fixes: fc79d4b104f0 ("9p: rdma: RDMA Transport Support for 9P")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>>   net/9p/trans_rdma.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
>> index 83f9100d46bf..da83023fecbf 100644
>> --- a/net/9p/trans_rdma.c
>> +++ b/net/9p/trans_rdma.c
>> @@ -499,6 +499,8 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req)
>>   
>>   	if (down_interruptible(&rdma->sq_sem)) {
>>   		err = -EINTR;
>> +		ib_dma_unmap_single(rdma->cm_id->device, c->busa,
>> +				    c->req->tc.size, DMA_TO_DEVICE);
>>   		goto send_error;
>>   	}
> 
> It is not the only place where ib_dma_unmap_single() wasn't called.
> Even at the same function if ib_post_send() fails, the unmap is not
> called. Also post_recv() is missing call to ib_dma_unmap_single() too.
> 
> Thanks
> 
Hi Leon:
	Thank you for your review. I'm sorry I haven't answered your
message for so long, I've got Coronavirus and it's a terrible feeling.
I will send v2 soon.

Zhengchao Shao
>>   
>> -- 
>> 2.34.1
>>
diff mbox series

Patch

diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 83f9100d46bf..da83023fecbf 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -499,6 +499,8 @@  static int rdma_request(struct p9_client *client, struct p9_req_t *req)
 
 	if (down_interruptible(&rdma->sq_sem)) {
 		err = -EINTR;
+		ib_dma_unmap_single(rdma->cm_id->device, c->busa,
+				    c->req->tc.size, DMA_TO_DEVICE);
 		goto send_error;
 	}