From: Minchan Kim Date: Mon, 3 Mar 2014 23:38:34 +0000 (-0800) Subject: zram: avoid null access when fail to alloc meta X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=db5d711e2db776f18219b033e5dc4fb7e4264dd7;p=openwrt%2Fstaging%2Fblogic.git zram: avoid null access when fail to alloc meta zram_meta_alloc could fail so caller should check it. Otherwise, your system will hang. Signed-off-by: Minchan Kim Acked-by: Jerome Marchand Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 011e55d820b1..51c557cfd92b 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -612,6 +612,8 @@ static ssize_t disksize_store(struct device *dev, disksize = PAGE_ALIGN(disksize); meta = zram_meta_alloc(disksize); + if (!meta) + return -ENOMEM; down_write(&zram->init_lock); if (zram->init_done) { up_write(&zram->init_lock);