Skip to content

Commit

Permalink
Staging: zram: Fix variable dereferenced before check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rashika Kheria authored and Greg Kroah-Hartman committed Oct 30, 2013
1 parent 238822b commit 59d3fe5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/staging/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 59d3fe5

Please sign in to comment.