mirror of
https://github.com/torvalds/linux.git
synced 2024-11-14 08:02:07 +00:00
VMCI: check return value of get_user_pages_fast() for errors
In a couple of places in qp_host_get_user_memory(),
get_user_pages_fast() is called without properly checking for errors. If
e.g. -EFAULT is returned, this negative value will then be passed on to
qp_release_pages(), which expects a u64 as input.
Fix this by only calling qp_release_pages() when we have a positive
number returned.
Fixes: 06164d2b72
("VMCI: queue pairs implementation.")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Link: https://lore.kernel.org/r/20200825164522.412392-1-alex.dewar90@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
da0d6b3a53
commit
90ca6333fd
@ -657,8 +657,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
|
||||
if (retval < (int)produce_q->kernel_if->num_pages) {
|
||||
pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
|
||||
retval);
|
||||
qp_release_pages(produce_q->kernel_if->u.h.header_page,
|
||||
retval, false);
|
||||
if (retval > 0)
|
||||
qp_release_pages(produce_q->kernel_if->u.h.header_page,
|
||||
retval, false);
|
||||
err = VMCI_ERROR_NO_MEM;
|
||||
goto out;
|
||||
}
|
||||
@ -670,8 +671,9 @@ static int qp_host_get_user_memory(u64 produce_uva,
|
||||
if (retval < (int)consume_q->kernel_if->num_pages) {
|
||||
pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
|
||||
retval);
|
||||
qp_release_pages(consume_q->kernel_if->u.h.header_page,
|
||||
retval, false);
|
||||
if (retval > 0)
|
||||
qp_release_pages(consume_q->kernel_if->u.h.header_page,
|
||||
retval, false);
|
||||
qp_release_pages(produce_q->kernel_if->u.h.header_page,
|
||||
produce_q->kernel_if->num_pages, false);
|
||||
err = VMCI_ERROR_NO_MEM;
|
||||
|
Loading…
Reference in New Issue
Block a user