]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: smbd: change the return value of get_sg_list
authorHyunchul Lee <hyc.lee@gmail.com>
Mon, 18 Dec 2023 15:32:56 +0000 (00:32 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:41:51 +0000 (10:41 +0100)
[ Upstream commit 4e3edd0092704b25626a0fe60a974f6f382ff93d ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ksmbd/transport_rdma.c

index 02271ebf418a978e25380ffebab27334ae5cc616..ca853433e4b4e3258fc0be71b80c7ea71cef1796 100644 (file)
@@ -1085,7 +1085,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);
@@ -1117,7 +1117,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);
 }