From patchwork Tue Jun 19 02:15:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9416 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 8665C23F19 for ; Tue, 19 Jun 2012 02:18:03 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4F9D2A18AA3 for ; Tue, 19 Jun 2012 02:18:03 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so4648181ggn.11 for ; Mon, 18 Jun 2012 19:18:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=RV1NICQBrfiOzb+SjfOfLHkD3RWay5lUcSiPtGooUW0=; b=fie6JIdr37ITV9DE+/dbnCJJJ5dnZiLvFU4EYbK+agHPztBRHNGn5CXzonum3Ouu1S Pq3ysD+DO6pfTpdZWfize6O7Gi764n8xkHYzAZV9n6YSFHU1WMy9dPBXyPp8TCS0U8kL 5iy3N38Cy/rnRwFImK/UJiuDpjfPjr1BK/WBMW4CzjFh2vU3RzulJSqgzmXxQaRGMU4t /lAHRa+PL5Ph1Ohx29uBUEJ2shD6wqcSN/83oR8VAnHsAOzQfrU0NEA4fBMBFW61kEb+ IqvVfqKpG0XSWZVHiqpo05Ujzm/dFkuygKtht+QWaQ4wpkMkY5+YiZpzNT/aUIk1oFHD Kb2Q== Received: by 10.50.87.227 with SMTP id bb3mr2295078igb.57.1340072282919; Mon, 18 Jun 2012 19:18:02 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp101043ibb; Mon, 18 Jun 2012 19:18:02 -0700 (PDT) Received: by 10.68.138.166 with SMTP id qr6mr58422515pbb.43.1340072282114; Mon, 18 Jun 2012 19:18:02 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id hw8si15924753pbc.176.2012.06.18.19.18.01 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 19:18:02 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so10377372pbb.37 for ; Mon, 18 Jun 2012 19:18:01 -0700 (PDT) Received: by 10.68.239.164 with SMTP id vt4mr57224456pbc.166.1340072281854; Mon, 18 Jun 2012 19:18:01 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id kt1sm25981810pbc.32.2012.06.18.19.17.58 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Jun 2012 19:18:01 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 2/7] pstore/ram: Fix error handling during przs allocation Date: Mon, 18 Jun 2012 19:15:51 -0700 Message-Id: <1340072156-6225-2-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120619021050.GA19387@lizard> References: <20120619021050.GA19387@lizard> X-Gm-Message-State: ALoCoQmhlqCYRgtGH2yjzWgq1l4Ng27IeSsVZp2AZWVFIRpwbBKeflfEue7rxQPrOwQZ1ofnNEbW persistent_ram_new() returns ERR_PTR() value on errors, so during freeing of the przs we should check for both NULL and IS_ERR() entries, otherwise bad things will happen. Signed-off-by: Anton Vorontsov Acked-by: Kees Cook --- fs/pstore/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 0b36e91..58b93fb 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -260,7 +260,7 @@ static void ramoops_free_przs(struct ramoops_context *cxt) if (!cxt->przs) return; - for (i = 0; cxt->przs[i]; i++) + for (i = 0; !IS_ERR_OR_NULL(cxt->przs[i]); i++) persistent_ram_free(cxt->przs[i]); kfree(cxt->przs); }