Staging: zram: Fix variable dereferenced before check
authorRashika Kheria <rashika.kheria@gmail.com>
Wed, 30 Oct 2013 13:13:32 +0000 (18:43 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Oct 2013 16:32:10 +0000 (09:32 -0700)
This patch fixes the following Smatch warning in zram_drv.c-
drivers/staging/zram/zram_drv.c:899
destroy_device() warn: variable dereferenced before check 'zram->disk' (see line 896)

Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/zram/zram_drv.c

index 2c4ed52ca849d45b385cbeed0d88a545d4a5fa5d..b704d06943f5ca3ed3db70c2ed1200d617cdf415 100644 (file)
@@ -896,13 +896,10 @@ static void destroy_device(struct zram *zram)
        sysfs_remove_group(&disk_to_dev(zram->disk)->kobj,
                        &zram_disk_attr_group);
 
-       if (zram->disk) {
-               del_gendisk(zram->disk);
-               put_disk(zram->disk);
-       }
+       del_gendisk(zram->disk);
+       put_disk(zram->disk);
 
-       if (zram->queue)
-               blk_cleanup_queue(zram->queue);
+       blk_cleanup_queue(zram->queue);
 }
 
 static int __init zram_init(void)