media: atomisp: Fixed error handling path
authorSouptick Joarder <jrdr.linux@gmail.com>
Sun, 27 Sep 2020 15:08:04 +0000 (17:08 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 22 Mar 2021 16:31:58 +0000 (17:31 +0100)
commit16a5dcf7fbc2f5cd10c1e6264262bfa3832fb7d5
tree6c80124dd0424c026399b621ceda4a08d2dc7248
parent491a0b208b15978c2bde9eb1a6b77a5e0eb55ad0
media: atomisp: Fixed error handling path

Inside alloc_user_pages() based on flag value either pin_user_pages()
or get_user_pages_fast() will be called. However, these API might fail.

But free_user_pages() called in error handling path doesn't bother
about return value and will try to unpin bo->pgnr pages, which is
incorrect.

Fix this by passing the page_nr to free_user_pages(). If page_nr > 0
pages will be unpinned based on bo->mem_type. This will also take care
of non error handling path.

allocation")

Link: https://lore.kernel.org/linux-media/1601219284-13275-1-git-send-email-jrdr.linux@gmail.com
Fixes: 14a638ab96c5 ("media: atomisp: use pin_user_pages() for memory
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/hmm/hmm_bo.c