From patchwork Tue Sep 25 09:57:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 11709 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 AD4FF23E41 for ; Tue, 25 Sep 2012 10:01:14 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id E2225A19083 for ; Tue, 25 Sep 2012 10:01:13 +0000 (UTC) Received: by ieje10 with SMTP id e10so12365584iej.11 for ; Tue, 25 Sep 2012 03:01:13 -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:x-gm-message-state; bh=TaWbYZEcy5/tyyKBndO+p3qb8THXRMYWkALooBTBbEU=; b=aR8rNWoHTGRQxvfSuYt2qN0GGHXwbINtS+E8wsOL57+r/PSNzhipV6k9i5YPVCSceR kupvuxLnFaTteuZzj7wem8lCyrmE6D7aVwuKVbijRfZEiyRMnsn80qqa+7mRbllthnA+ TXmZsXoo115wIvL0JvTWFQNkgcx+4t/NqvPJzV/Ku/pn2OKXURrx/AGmQcyjQzRWPdqP QX1tfa94VRjviEQVO9Yg36JudCz1it4DpxCZTAThtTP5JcaTp/ElL3ouqGLjYjZCO7Bg nXljj9lZHQfqBZCcGOuxHHEZt3WQfsJo948tjg00PcI6J5aaZ8myxjapkuIAdWArozyf fU1g== Received: by 10.50.217.229 with SMTP id pb5mr7731267igc.28.1348567271903; Tue, 25 Sep 2012 03:01:11 -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.50.184.232 with SMTP id ex8csp285271igc; Tue, 25 Sep 2012 03:01:11 -0700 (PDT) Received: by 10.68.135.234 with SMTP id pv10mr22055466pbb.156.1348567270433; Tue, 25 Sep 2012 03:01:10 -0700 (PDT) Received: from mail-da0-f50.google.com (mail-da0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id e7si7132923pay.172.2012.09.25.03.01.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 03:01:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by daez20 with SMTP id z20so362020dae.37 for ; Tue, 25 Sep 2012 03:01:10 -0700 (PDT) Received: by 10.68.224.138 with SMTP id rc10mr44423184pbc.34.1348567270089; Tue, 25 Sep 2012 03:01:10 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id pa6sm92456pbc.71.2012.09.25.03.01.06 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 03:01:09 -0700 (PDT) From: Sachin Kamat To: linux-mtd@lists.infradead.org Cc: dwmw2@infradead.org, dedekind1@gmail.com, sachin.kamat@linaro.org, patches@linaro.org, Dmitry Eremin-Solenikov , Artem Bityutskiy Subject: [PATCH] mtd: ofpart: Fix incorrect NULL check in parse_ofoldpart_partitions() Date: Tue, 25 Sep 2012 15:27:13 +0530 Message-Id: <1348567033-5418-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQn/ni+JHAo0ytecK6SyAqxAc91vETRAJPJKH9EBaEcXn7S0bb87munwC8EeE8oy7FJeo7gO The pointer returned by kzalloc should be tested for NULL to avoid potential NULL pointer dereference later. Incorrect pointer was being tested for NULL. Bug introduced by commit fbcf62a3 (mtd: physmap_of: move parse_obsolete_partitions to become separate parser). This patch fixes this bug. Cc: Dmitry Eremin-Solenikov Cc: Artem Bityutskiy Signed-off-by: Sachin Kamat --- drivers/mtd/ofpart.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 64be8f0..d9127e2 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c @@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, nr_parts = plen / sizeof(part[0]); *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL); - if (!pparts) + if (!*pparts) return -ENOMEM; names = of_get_property(dp, "partition-names", &plen);