Skip to content

Commit 98e3e2b

Browse files
Thomas-fouriersmfrench
authored andcommitted
ksmbd: smbd: fix dma_unmap_sg() nents
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned. Fixes: 0626e66 ("cifsd: add server handler for central processing and tranport layers") Cc: <stable@vger.kernel.org> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 24d479d commit 98e3e2b

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

fs/smb/server/transport_rdma.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,14 +1353,12 @@ static int get_sg_list(void *buf, int size, struct scatterlist *sg_list, int nen
13531353

13541354
static int get_mapped_sg_list(struct ib_device *device, void *buf, int size,
13551355
struct scatterlist *sg_list, int nentries,
1356-
enum dma_data_direction dir)
1356+
enum dma_data_direction dir, int *npages)
13571357
{
1358-
int npages;
1359-
1360-
npages = get_sg_list(buf, size, sg_list, nentries);
1361-
if (npages < 0)
1358+
*npages = get_sg_list(buf, size, sg_list, nentries);
1359+
if (*npages < 0)
13621360
return -EINVAL;
1363-
return ib_dma_map_sg(device, sg_list, npages, dir);
1361+
return ib_dma_map_sg(device, sg_list, *npages, dir);
13641362
}
13651363

13661364
static int post_sendmsg(struct smbdirect_socket *sc,
@@ -1431,20 +1429,21 @@ static int smb_direct_post_send_data(struct smbdirect_socket *sc,
14311429
for (i = 0; i < niov; i++) {
14321430
struct ib_sge *sge;
14331431
int sg_cnt;
1432+
int npages;
14341433

14351434
sg_init_table(sg, SMBDIRECT_SEND_IO_MAX_SGE - 1);
14361435
sg_cnt = get_mapped_sg_list(sc->ib.dev,
14371436
iov[i].iov_base, iov[i].iov_len,
14381437
sg, SMBDIRECT_SEND_IO_MAX_SGE - 1,
1439-
DMA_TO_DEVICE);
1438+
DMA_TO_DEVICE, &npages);
14401439
if (sg_cnt <= 0) {
14411440
pr_err("failed to map buffer\n");
14421441
ret = -ENOMEM;
14431442
goto err;
14441443
} else if (sg_cnt + msg->num_sge > SMBDIRECT_SEND_IO_MAX_SGE) {
14451444
pr_err("buffer not fitted into sges\n");
14461445
ret = -E2BIG;
1447-
ib_dma_unmap_sg(sc->ib.dev, sg, sg_cnt,
1446+
ib_dma_unmap_sg(sc->ib.dev, sg, npages,
14481447
DMA_TO_DEVICE);
14491448
goto err;
14501449
}

0 commit comments

Comments
 (0)