zram: fix double free backing device
[sfrench/cifs-2.6.git] / drivers / block / zram / zram_drv.c
index 21a7046958a3b70c5d0ef4015a7f7a64c6a4dc6e..d1459cc1159ffdfbea96cc210dff2d665ccdf84d 100644 (file)
@@ -387,8 +387,10 @@ static ssize_t backing_dev_store(struct device *dev,
 
        bdev = bdgrab(I_BDEV(inode));
        err = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, zram);
 
        bdev = bdgrab(I_BDEV(inode));
        err = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, zram);
-       if (err < 0)
+       if (err < 0) {
+               bdev = NULL;
                goto out;
                goto out;
+       }
 
        nr_pages = i_size_read(inode) >> PAGE_SHIFT;
        bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);
 
        nr_pages = i_size_read(inode) >> PAGE_SHIFT;
        bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);