Skip to content

Commit 73274c3

Browse files
Dan Carpenterquic-jhugo
authored andcommitted
accel/qaic: Fix a leak in map_user_pages()
If get_user_pages_fast() allocates some pages but not as many as we wanted, then the current code leaks those pages. Call put_page() on the pages before returning. Fixes: 129776a ("accel/qaic: Add control path") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Pranjal Ramajor Asha Kanojiya <quic_pkanojiy@quicinc.com> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Reviewed-by: Dafna Hirschfeld <dhirschfeld@habana.ai> Cc: stable@vger.kernel.org # 6.4.x Signed-off-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Link: https://patchwork.freedesktop.org/patch/msgid/ZK0Q+ZuONTsBG+1T@moroto
1 parent 47d87f7 commit 73274c3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/accel/qaic/qaic_control.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,12 @@ static int find_and_map_user_pages(struct qaic_device *qdev,
419419
}
420420

421421
ret = get_user_pages_fast(xfer_start_addr, nr_pages, 0, page_list);
422-
if (ret < 0 || ret != nr_pages) {
423-
ret = -EFAULT;
422+
if (ret < 0)
424423
goto free_page_list;
424+
if (ret != nr_pages) {
425+
nr_pages = ret;
426+
ret = -EFAULT;
427+
goto put_pages;
425428
}
426429

427430
sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);

0 commit comments

Comments
 (0)