diff options
author | Farhan Ali <alifm@linux.ibm.com> | 2019-07-11 16:28:53 +0200 |
---|---|---|
committer | Cornelia Huck <cohuck@redhat.com> | 2019-07-15 14:16:37 +0200 |
commit | c1ab69268d124ebdbb3864580808188ccd3ea355 (patch) | |
tree | 482613c97147ed7fedb7fa517db7d6a0eb95ebbe /drivers/s390 | |
parent | vfio-ccw: Fix memory leak and don't call cp_free in cp_init (diff) | |
download | linux-c1ab69268d124ebdbb3864580808188ccd3ea355.tar.xz linux-c1ab69268d124ebdbb3864580808188ccd3ea355.zip |
vfio-ccw: Set pa_nr to 0 if memory allocation fails for pa_iova_pfn
So we don't call try to call vfio_unpin_pages() incorrectly.
Fixes: 0a19e61e6d4c ("vfio: ccw: introduce channel program interfaces")
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <33a89467ad6369196ae6edf820cbcb1e2d8d050c.1562854091.git.alifm@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/cio/vfio_ccw_cp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c index e4e8724eddaa..3645d1720c4b 100644 --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -72,8 +72,10 @@ static int pfn_array_alloc(struct pfn_array *pa, u64 iova, unsigned int len) 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; |