Skip to content

Commit

Permalink
zram: avoid null access when fail to alloc meta
Browse files Browse the repository at this point in the history
zram_meta_alloc could fail so caller should check it.  Otherwise, your
system will hang.

Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Minchan Kim authored and Linus Torvalds committed Mar 4, 2014
1 parent a5f6ea2 commit db5d711
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit db5d711

Please sign in to comment.