VMCI: check return value of get_user_pages_fast() for errors
authorAlex Dewar <alex.dewar90@gmail.com>
Tue, 25 Aug 2020 16:45:18 +0000 (17:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:07:04 +0000 (09:07 +0100)
commit2b8c7395d275caa8bd2bcda282ba889c727095dc
tree90898646bf7e6188bbd1ed7cea6143e8e7bf4ce4
parent6630474d70c0c3cb80ad480b4bf0c813dbc4e9db
VMCI: check return value of get_user_pages_fast() for errors

[ Upstream commit 90ca6333fd65f318c47bff425e1ea36c0a5539f6 ]

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: 06164d2b72aa ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/misc/vmw_vmci/vmci_queue_pair.c