Commit 7fb2fd4e authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

vmci: type promotion bug in qp_host_get_user_memory()

The problem is that if get_user_pages_fast() fails and returns a
negative error code, it gets type promoted to a high positive value and
treated as a success.

Fixes: 06164d2b ("VMCI: queue pairs implementation.")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fc82975a
...@@ -668,7 +668,7 @@ static int qp_host_get_user_memory(u64 produce_uva, ...@@ -668,7 +668,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
retval = get_user_pages_fast((uintptr_t) produce_uva, retval = get_user_pages_fast((uintptr_t) produce_uva,
produce_q->kernel_if->num_pages, 1, produce_q->kernel_if->num_pages, 1,
produce_q->kernel_if->u.h.header_page); produce_q->kernel_if->u.h.header_page);
if (retval < produce_q->kernel_if->num_pages) { if (retval < (int)produce_q->kernel_if->num_pages) {
pr_debug("get_user_pages_fast(produce) failed (retval=%d)", pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
retval); retval);
qp_release_pages(produce_q->kernel_if->u.h.header_page, qp_release_pages(produce_q->kernel_if->u.h.header_page,
...@@ -680,7 +680,7 @@ static int qp_host_get_user_memory(u64 produce_uva, ...@@ -680,7 +680,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
retval = get_user_pages_fast((uintptr_t) consume_uva, retval = get_user_pages_fast((uintptr_t) consume_uva,
consume_q->kernel_if->num_pages, 1, consume_q->kernel_if->num_pages, 1,
consume_q->kernel_if->u.h.header_page); consume_q->kernel_if->u.h.header_page);
if (retval < consume_q->kernel_if->num_pages) { if (retval < (int)consume_q->kernel_if->num_pages) {
pr_debug("get_user_pages_fast(consume) failed (retval=%d)", pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
retval); retval);
qp_release_pages(consume_q->kernel_if->u.h.header_page, qp_release_pages(consume_q->kernel_if->u.h.header_page,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment