Commit 6f9dff8d authored by Farhan Ali's avatar Farhan Ali Committed by Greg Kroah-Hartman

vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn

[ Upstream commit c1ab6926 ]

So we don't call try to call vfio_unpin_pages() incorrectly.

Fixes: 0a19e61e ("vfio: ccw: introduce channel program interfaces")
Signed-off-by: default avatarFarhan Ali <alifm@linux.ibm.com>
Reviewed-by: default avatarEric Farman <farman@linux.ibm.com>
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Message-Id: <33a89467ad6369196ae6edf820cbcb1e2d8d050c.1562854091.git.alifm@linux.ibm.com>
Signed-off-by: default avatarCornelia Huck <cohuck@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent bb312b4a
......@@ -89,8 +89,10 @@ static int pfn_array_alloc_pin(struct pfn_array *pa, struct device *mdev,
sizeof(*pa->pa_iova_pfn) +
sizeof(*pa->pa_pfn),
GFP_KERNEL);
if (unlikely(!pa->pa_iova_pfn))
if (unlikely(!pa->pa_iova_pfn)) {
pa->pa_nr = 0;
return -ENOMEM;
}
pa->pa_pfn = pa->pa_iova_pfn + pa->pa_nr;
pa->pa_iova_pfn[0] = pa->pa_iova >> PAGE_SHIFT;
......
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