diff options
author | Colin Ian King <colin.king@canonical.com> | 2018-07-31 15:02:25 +0100 |
---|---|---|
committer | Boris Ostrovsky <boris.ostrovsky@oracle.com> | 2018-07-31 12:59:13 -0400 |
commit | 2789e83c933d7da583e592d7958e87493c889605 (patch) | |
tree | 0b8684759ec73bf0125293bb2fd884ba050646d5 /drivers/xen | |
parent | 47b428d14f06dbeab23dd5c7e424e15283841765 (diff) | |
download | linux-rpi3-2789e83c933d7da583e592d7958e87493c889605.tar.gz linux-rpi3-2789e83c933d7da583e592d7958e87493c889605.tar.bz2 linux-rpi3-2789e83c933d7da583e592d7958e87493c889605.zip |
xen/gntdev: don't dereference a null gntdev_dmabuf on allocation failure
Currently when the allocation of gntdev_dmabuf fails, the error exit
path will call dmabuf_imp_free_storage and causes a null pointer
dereference on gntdev_dmabuf. Fix this by adding an error exit path
that won't free gntdev_dmabuf.
Detected by CoverityScan, CID#1472124 ("Dereference after null check")
Fixes: bf8dc55b1358 ("xen/gntdev: Implement dma-buf import functionality")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/gntdev-dmabuf.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index faaa4d3970ea..589fd923c550 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c @@ -569,7 +569,7 @@ static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count) gntdev_dmabuf = kzalloc(sizeof(*gntdev_dmabuf), GFP_KERNEL); if (!gntdev_dmabuf) - goto fail; + goto fail_no_free; gntdev_dmabuf->u.imp.refs = kcalloc(count, sizeof(gntdev_dmabuf->u.imp.refs[0]), @@ -592,6 +592,7 @@ static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(int count) fail: dmabuf_imp_free_storage(gntdev_dmabuf); +fail_no_free: return ERR_PTR(-ENOMEM); } |