block: xen-blkback: add null check to avoid null pointer dereference
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Thu, 11 May 2017 15:27:35 +0000 (10:27 -0500)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 15 May 2017 21:14:28 +0000 (17:14 -0400)
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>
drivers/block/xen-blkback/xenbus.c

index 8fe61b5dc5a6553d141950506344fe90bbfde2c8..1f3dfaa54d871a36897408898c1e0e9f22100bb1 100644 (file)
@@ -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;