summary refs log tree commit diff
path: root/drivers/block/xen-blkback/xenbus.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <garsilva@embeddedor.com>2017-05-11 10:27:35 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2017-05-15 17:14:28 -0400
commit2d4456c73a487abe53863e10641c2f73537edf5c (patch)
tree93b18adce07e85693f4e86c45ff353e6bcd4ab1b /drivers/block/xen-blkback/xenbus.c
parent89515d0255c918e08aa4085956c79bf17615fda5 (diff)
downloadlinux-2d4456c73a487abe53863e10641c2f73537edf5c.tar.gz
block: xen-blkback: add null check to avoid null pointer dereference
Add null check before calling xen_blkif_put() to avoid potential
null pointer dereference.

Addresses-Coverity-ID: 1350942
Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback/xenbus.c')
-rw-r--r--drivers/block/xen-blkback/xenbus.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 8fe61b5dc5a6..1f3dfaa54d87 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -504,11 +504,13 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
 
 	dev_set_drvdata(&dev->dev, NULL);
 
-	if (be->blkif)
+	if (be->blkif) {
 		xen_blkif_disconnect(be->blkif);
 
-	/* Put the reference we set in xen_blkif_alloc(). */
-	xen_blkif_put(be->blkif);
+		/* Put the reference we set in xen_blkif_alloc(). */
+		xen_blkif_put(be->blkif);
+	}
+
 	kfree(be->mode);
 	kfree(be);
 	return 0;