Staging: zram: Fix variable dereferenced before check
authorRashika Kheria <rashika.kheria@gmail.com>
Wed, 30 Oct 2013 13:13:32 +0000 (18:43 +0530)
committerAlex Shi <alex.shi@linaro.org>
Mon, 11 May 2015 09:36:31 +0000 (17:36 +0800)
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>
(cherry picked from commit 59d3fe540454dd8fc48d4eda44e200f9c98bef10)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
drivers/staging/zram/zram_drv.c

index 7d8ff31f67f2d98fbc0f244b4c5e208fbe6b09a4..a125cfae6942e2e77cd20a057e6bd629957a2fc3 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)