From patchwork Fri Nov 16 10:38:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 12899 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 C653823EFB for ; Fri, 16 Nov 2012 10:44:23 +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 5E5B6A19688 for ; Fri, 16 Nov 2012 10:44:23 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so3237308iej.11 for ; Fri, 16 Nov 2012 02:44:22 -0800 (PST) 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=1PU5ZH/Yq7YlbD44IZLmV8U8K9IHomixmpUMwu6sWKA=; b=Q3RBcA7u0HuIhUR7NjdhRbQnkeO9D7Qq+3CIdjJ80x4o7CYniA5jr8RjDoHrPtiWXX qYZ/RBstdKnPLiFDywbSmzohQSjKpflTSfmVJvS1OGRDqOcw43OU3psj+bo1sCZAPSgW BoZaYSMHgJpY2lH/ilGI+LC2wLKujSjxg4XwCDo1/yUCbnlsm47wm46LjXNeKvLTRXcF xGTbEQRuOHWXXQO7YvP+KNk78eHE4h3THXKfLKPldj452dExUtfmANUxn9Fx1ciSeBYC FXm79C+O/8XXBgrBnDmubWwlt1kBWTBE7u9Or6PMsytjAhkl8OBAoecZt5kuFF/I2Pjp +T1A== Received: by 10.50.173.34 with SMTP id bh2mr2588306igc.70.1353062662789; Fri, 16 Nov 2012 02:44:22 -0800 (PST) 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.67.148 with SMTP id n20csp45974igt; Fri, 16 Nov 2012 02:44:22 -0800 (PST) Received: by 10.68.197.71 with SMTP id is7mr13680420pbc.79.1353062662082; Fri, 16 Nov 2012 02:44:22 -0800 (PST) Received: from mail-da0-f47.google.com (mail-da0-f47.google.com [209.85.210.47]) by mx.google.com with ESMTPS id wn5si2185433pbc.136.2012.11.16.02.44.21 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Nov 2012 02:44:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.47 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.47; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.47 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-da0-f47.google.com with SMTP id s35so1014904dak.6 for ; Fri, 16 Nov 2012 02:44:21 -0800 (PST) Received: by 10.66.80.166 with SMTP id s6mr11746416pax.21.1353062661757; Fri, 16 Nov 2012 02:44:21 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id k9sm896658paz.22.2012.11.16.02.44.18 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Nov 2012 02:44:20 -0800 (PST) From: Sachin Kamat To: linux-mtd@lists.infradead.org Cc: dwmw2@infradead.org, dedekind1@gmail.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH Resend] mtd: s3c2410: Fix potential NULL pointer dereference error Date: Fri, 16 Nov 2012 16:08:22 +0530 Message-Id: <1353062302-10266-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQl/6Cg0/YnRsKHdEjpdsc+LF6uhJMkFX69KwYHZ5Z/raZ+uhwtFlu3H/d2QWocSf+XoGtlI 'set' is tested for NULL. But subsequently accessed without the check. Thus making it conditional to avoid NULL pointer dereferencing. Signed-off-by: Sachin Kamat --- drivers/mtd/nand/s3c2410.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index 295e4be..bbc49c4 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -730,11 +730,14 @@ static int s3c2410_nand_add_partition(struct s3c2410_nand_info *info, struct s3c2410_nand_mtd *mtd, struct s3c2410_nand_set *set) { - if (set) + if (set) { mtd->mtd.name = set->name; - return mtd_device_parse_register(&mtd->mtd, NULL, NULL, + return mtd_device_parse_register(&mtd->mtd, NULL, NULL, set->partitions, set->nr_partitions); + } + + return -ENODEV; } /**