Skip to content

Commit

Permalink
ksmbd: smbd: change the return value of get_sg_list
Browse files Browse the repository at this point in the history
Make get_sg_list return EINVAL if there aren't
mapped scatterlists.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Hyunchul Lee authored and Steve French committed May 21, 2022
1 parent 11659a8 commit 4e3edd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/ksmbd/transport_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ static int get_sg_list(void *buf, int size, struct scatterlist *sg_list, int nen
int offset, len;
int i = 0;

if (nentries < get_buf_page_count(buf, size))
if (size <= 0 || nentries < get_buf_page_count(buf, size))
return -EINVAL;

offset = offset_in_page(buf);
Expand Down Expand Up @@ -1111,7 +1111,7 @@ static int get_mapped_sg_list(struct ib_device *device, void *buf, int size,
int npages;

npages = get_sg_list(buf, size, sg_list, nentries);
if (npages <= 0)
if (npages < 0)
return -EINVAL;
return ib_dma_map_sg(device, sg_list, npages, dir);
}
Expand Down

0 comments on commit 4e3edd0

Please sign in to comment.