Staging: zram: Fix access of NULL pointer
authorRashika Kheria <rashika.kheria@gmail.com>
Wed, 30 Oct 2013 13:06:32 +0000 (18:36 +0530)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 15 May 2014 05:27:59 +0000 (07:27 +0200)
commit44820c4a870d5e27e26051a7c0a132dfe2bd7408
tree7f83b32a059e76c6b1fc3caf5a2ac61981092309
parent11b7ec00af8412e043bb84016b7d85670f2459fd
Staging: zram: Fix access of NULL pointer

This patch fixes the bug in reset_store caused by accessing NULL pointer.

The bdev gets its value from bdget_disk() which could fail when memory
pressure is severe and hence can return NULL because allocation of
inode in bdget could fail.

Hence, this patch introduces a check for bdev to prevent reference to a
NULL pointer in the later part of the code. It also removes unnecessary
check of bdev for fsync_bdev().

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