Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752558AbaDAMJf (ORCPT ); Tue, 1 Apr 2014 08:09:35 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42265 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751963AbaDALQw (ORCPT ); Tue, 1 Apr 2014 07:16:52 -0400 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Minchan Kim , Andrew Morton , Linus Torvalds , Luis Henriques Subject: [PATCH 3.11 041/144] zram: avoid null access when fail to alloc meta Date: Tue, 1 Apr 2014 12:14:05 +0100 Message-Id: <1396350948-29910-42-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396350948-29910-1-git-send-email-luis.henriques@canonical.com> References: <1396350948-29910-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.11 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.11.10.7 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Minchan Kim commit db5d711e2db776f18219b033e5dc4fb7e4264dd7 upstream. zram_meta_alloc could fail so caller should check it. Otherwise, your system will hang. Signed-off-by: Minchan Kim Acked-by: Jerome Marchand Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds [ luis: backported to 3.11: - zram is a staging driver in 3.11 kernel ] Signed-off-by: Luis Henriques --- drivers/staging/zram/zram_drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index fc540ea..9f1cb4e0 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -620,6 +620,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); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/