linux/drivers/misc/mic/scif
Souptick Joarder 62c3270489 misc: mic: scif: Fix error handling path
[ Upstream commit a81072a9c0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-29 09:55:11 +01:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
scif_api.c misc: mic: SCIF Fix scif_get_new_port() error handling 2018-08-05 16:29:11 +02:00
scif_debugfs.c
scif_dma.c mm, oom: distinguish blockable mode for mmu notifiers 2018-08-22 10:52:44 -07:00
scif_epd.c
scif_epd.h the rest of drivers/*: annotate ->poll() instances 2017-11-28 11:06:58 -05:00
scif_fd.c the rest of drivers/*: annotate ->poll() instances 2017-11-28 11:06:58 -05:00
scif_fence.c misc: mic: fix a DMA pool free failure 2019-12-01 09:16:22 +01:00
scif_main.c
scif_main.h sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
scif_map.h
scif_mmap.c
scif_nm.c
scif_nodeqp.c
scif_nodeqp.h
scif_peer_bus.c
scif_peer_bus.h
scif_ports.c
scif_rb.c locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() 2017-10-25 11:01:08 +02:00
scif_rb.h
scif_rma_list.c locking/atomics: COCCINELLE/treewide: Convert trivial ACCESS_ONCE() patterns to READ_ONCE()/WRITE_ONCE() 2017-10-25 11:01:08 +02:00
scif_rma_list.h
scif_rma.c misc: mic: scif: Fix error handling path 2020-10-29 09:55:11 +01:00
scif_rma.h