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: 186752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3D9512C008D for ; Tue, 25 Sep 2012 20:02:17 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TGRx6-0008HO-0v; Tue, 25 Sep 2012 10:01:16 +0000 Received: from mail-pb0-f49.google.com ([209.85.160.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TGRx2-0008Fl-2T for linux-mtd@lists.infradead.org; Tue, 25 Sep 2012 10:01:13 +0000 Received: by pbbrq8 with SMTP id rq8so14809947pbb.36 for ; Tue, 25 Sep 2012 03:01:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=TaWbYZEcy5/tyyKBndO+p3qb8THXRMYWkALooBTBbEU=; b=UMSD5w6+iShOrojrcBIToBXGLamBk4wjU7cSyaJyD0q/eJMv74cuJCYtzzaMOiLo8U QEGi7HmI0u6+CzZaFCSZoCGsX+KwV1U4aDGVQqgCYKddSYfPv9Bk18k/gB/flGIJAcaV V3yCPGR+N7nniHbgLvBk0EqRru3LdPghaAKX7GB4shQgMGjlQlfctiDgI66g20bPZ4mf +u7wtRKh+8zK3Xx5recDhdGXoixTpmUL15w6518jzt8IckqZToLdpV1vq6MWziBEiW4P 2byP/r5ej4p0YexmmOW31LKTYywx5dySHABM502Jk19IwypFnqJq4gcIHuBT+3r3mQ61 bjPQ== 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 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: ALoCoQnsqSyy6Gd7ahMBO2mNntp9qXu+aCHEo+v7L4esJBadeGLyW7ZOXRtKLnm5h0+i4wYOvbzd X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: patches@linaro.org, sachin.kamat@linaro.org, dedekind1@gmail.com, Dmitry Eremin-Solenikov , Artem Bityutskiy , dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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);