smb: client: Fix error cleanup in smb_extract_iter_to_rdma()
Subsystems (5)
PATCH 1/1 smb: client: Fix error cleanup in smb_extract_iter_to_rdma()
Fix smb_extract_iter_to_rdma() to use pre-decrement, not post-decrement, so that it cleans up the correct slots.
--- fs/smb/client/smbdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smbdirect.c +1 -1
@@ -3394,7 +3394,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,if (ret <0 ) {while (rdma->nr_sge > before) { -struct ib_sge *sge = &rdma->sge[rdma->nr_sge--]; +struct ib_sge *sge = &rdma->sge[--rdma->nr_sge];ib_dma_unmap_single (rdma->device, sge->addr, sge->length, rdma->direction);
Greg KH
maintainerQuoted 24 lines · David Howells
Fix
smb_extract_iter_to_rdma()to use pre-decrement, not post-decrement, so that it cleans up the correct slots.Fixes e5fbdde43017 ("cifs: Add a function to build an RDMA SGE list from an iterator")Signed-off-by David Howells <[email protected]>cc Steve French <[email protected]>cc Stefan Metzmacher <[email protected]>cc Paulo Alcantara <[email protected]>cc Tom Talpey <[email protected]>--- fs/smb/client/smbdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smbdirect.c +0
-0
fs/smb/client/smbdirect.c static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len, · line 3400
Quoted 8 lines
fs/smb/client/smbdirect.c +1
-1@@ -3394,7 +3394,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,if (ret <0 ) {while (rdma->nr_sge > before) { -struct ib_sge *sge = &rdma->sge[rdma->nr_sge--]; +struct ib_sge *sge = &rdma->sge[--rdma->nr_sge];ib_dma_unmap_single (rdma->device, sge->addr, sge->length, rdma->direction);
<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
Stefan Metzmacher
reviewerHi David,
Quoted 22 lines
Quoted 22 lines
Fix
smb_extract_iter_to_rdma()to use pre-decrement, not post-decrement, so that it cleans up the correct slots.Fixes e5fbdde43017 ("cifs: Add a function to build an RDMA SGE list from an iterator")Signed-off-by David Howells <[email protected]>cc Steve French <[email protected]>cc Stefan Metzmacher <[email protected]>cc Paulo Alcantara <[email protected]>cc Tom Talpey <[email protected]>--- fs/smb/client/smbdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/smb/client/smbdirect.c +0
-0@@ -3394,7 +3394,7 @@ static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,
Quoted 4 lines
fs/smb/client/smbdirect.c static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len, · line 3397
Quoted 4 lines
fs/smb/client/smbdirect.c +1
-1if (ret <0 ) {while (rdma->nr_sge > before) { -struct ib_sge *sge = &rdma->sge[rdma->nr_sge--]; +struct ib_sge *sge = &rdma->sge[--rdma->nr_sge];
Can you please use logic like this?
- while (state->num_sge > before) {
- struct ib_sge *sge = &state->sge[state->num_sge--];
+ for (size_t i = before; i < state->num_sge; i++) {
+ struct ib_sge *sge = &state->sge[i];
At least for me that is much easier to understand.
And as Greg pointed out we first need a fix for upstream, there the function is smbdirect_map_sges_from_iter in fs/smb/smbdirect/connection.c
Also the commit message needs to be adjusted for the new name.
Then we need a backportable fix for smb_extract_iter_to_rdma in fs/smb/client/smbdirect.c with the same logic.
Thanks!
metze
Quoted 12 lines
fs/smb/client/smbdirect.c static ssize_t smb_extract_iter_to_rdma(struct iov_iter *iter, size_t len,
Quoted 4 lines
fs/smb/client/smbdirect.c +0
-0ib_dma_unmap_single (rdma->device, sge->addr, sge->length, rdma->direction);<formletter>
This is not the correct way to submit patches for inclusion in the stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.</formletter>