Staging: zram: Fix access of NULL pointer
authorRashika Kheria <rashika.kheria@gmail.com>
Wed, 30 Oct 2013 13:06:32 +0000 (18:36 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Nov 2013 19:27:56 +0000 (11:27 -0800)
commit5cf7798500bbdf71d6587d108c48364d69331c79
treef1689b907a27b0cc967902199f178c7bcb77a85d
parentdf24f94953e79dc1fb8c559f7df256861025ff49
Staging: zram: Fix access of NULL pointer

commit 46a51c80216cb891f271ad021f59009f34677499 upstream.

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().

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