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 <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>
This commit is contained in:
parent
a5f6ea29f9
commit
db5d711e2d
|
@ -612,6 +612,8 @@ static ssize_t disksize_store(struct device *dev,
|
||||||
|
|
||||||
disksize = PAGE_ALIGN(disksize);
|
disksize = PAGE_ALIGN(disksize);
|
||||||
meta = zram_meta_alloc(disksize);
|
meta = zram_meta_alloc(disksize);
|
||||||
|
if (!meta)
|
||||||
|
return -ENOMEM;
|
||||||
down_write(&zram->init_lock);
|
down_write(&zram->init_lock);
|
||||||
if (zram->init_done) {
|
if (zram->init_done) {
|
||||||
up_write(&zram->init_lock);
|
up_write(&zram->init_lock);
|
||||||
|
|
Loading…
Reference in New Issue