xen-blkfront: free resources if xlvbd_alloc_gendisk fails
authorBob Liu <bob.liu@oracle.com>
Wed, 27 Jul 2016 09:42:04 +0000 (17:42 +0800)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 19 Aug 2016 16:31:59 +0000 (12:31 -0400)
Current code forgets to free resources in the failure path of
xlvbd_alloc_gendisk(), this patch fix it.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkfront.c

index f84e220..88ef6d4 100644 (file)
@@ -2442,7 +2442,7 @@ static void blkfront_connect(struct blkfront_info *info)
        if (err) {
                xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s",
                                 info->xbdev->otherend);
-               return;
+               goto fail;
        }
 
        xenbus_switch_state(info->xbdev, XenbusStateConnected);
@@ -2455,6 +2455,11 @@ static void blkfront_connect(struct blkfront_info *info)
        device_add_disk(&info->xbdev->dev, info->gd);
 
        info->is_ready = 1;
+       return;
+
+fail:
+       blkif_free(info, 0);
+       return;
 }
 
 /**