linux-stable/drivers/misc/mic
Souptick Joarder a81072a9c0 misc: mic: scif: Fix error handling path
Inside __scif_pin_pages(), when map_flags != SCIF_MAP_KERNEL it
will call pin_user_pages_fast() to map nr_pages. However,
pin_user_pages_fast() might fail with a return value -ERRNO.

The return value is stored in pinned_pages->nr_pages. which in
turn is passed to unpin_user_pages(), which expects
pinned_pages->nr_pages >=0, else disaster.

Fix this by assigning pinned_pages->nr_pages to 0 if
pin_user_pages_fast() returns -ERRNO.

Fixes: ba612aa8b4 ("misc: mic: SCIF memory registration and unregistration")
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Link: https://lore.kernel.org/r/1600570295-29546-1-git-send-email-jrdr.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-09-22 18:53:47 +02:00
..
bus treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 290 2019-06-05 17:36:38 +02:00
card misc: mic: card: mic_debugfs: Demote function headers from kerneldoc 2020-07-01 15:08:03 +02:00
common treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 290 2019-06-05 17:36:38 +02:00
cosm misc: mic: cosm: cosm_debugfs: Demote function headers from kerneldoc 2020-07-01 15:08:04 +02:00
cosm_client treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 290 2019-06-05 17:36:38 +02:00
host misc: mic: host: mic_debugfs: Demote function headers from kerneldoc 2020-07-01 15:08:03 +02:00
scif misc: mic: scif: Fix error handling path 2020-09-22 18:53:47 +02:00
vop vop: sparse warning fixup 2020-07-10 14:58:00 +02:00
Kconfig dma-mapping: make support for dma ops optional 2020-07-19 09:29:23 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00