From patchwork Thu Nov 15 04:56:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1746961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 48EE4DF2AB for ; Thu, 15 Nov 2012 04:58:17 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TYrUw-0004Ch-Ut; Thu, 15 Nov 2012 04:56:19 +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 1TYrUq-0004B5-QV for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2012 04:56:15 +0000 Received: by mail-pb0-f49.google.com with SMTP id un15so834599pbc.36 for ; Wed, 14 Nov 2012 20:56:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version :x-gm-message-state; bh=3PZXfhow889azZvxMT2R/qq3D8iFvFpeVZnVuSL7cHs=; b=OsYLjWSkxN3QpVi12iOw4/op+DIRl1N6xMwfhiTg+za+EcSoxjMtTmZ7yMOfDhr9jc gdplmHs8cK59+QC9o2C2ZeLIz+T6yXbQ91nMbNuYKfkLYj53CirfgcMzHwkcbrxygixS Pg3QUHJsG9le1LQnBIg7cbdDduoMrU3Lp6yBCfy7VsjWx4g5LNQJASnav3BkQU3UvceP jOBJ60NJ96qlBkUPwwnxq+3N4jG/K88sboVx3Jd4PcNpvX0cAEEI3FsamPnQ9QCUq7cw XlkfTO0i6yN/j39L4r125VKZ+hmk3A3qehGD0wYHQogbNYLElllNn0VuG6H72rtHmZIW 9mmw== Received: by 10.66.76.39 with SMTP id h7mr12809614paw.61.1352955371615; Wed, 14 Nov 2012 20:56:11 -0800 (PST) Received: from [192.168.0.100] (114-39-103-166.dynamic.hinet.net. [114.39.103.166]) by mx.google.com with ESMTPS id qj6sm8867926pbb.69.2012.11.14.20.56.08 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 20:56:11 -0800 (PST) Message-ID: <1352955365.6793.6.camel@phoenix> Subject: [PATCH 4/4] pinctrl: nomadik: Prevent NULL dereference if of_match_device returns NULL From: Axel Lin To: Linus Walleij Date: Thu, 15 Nov 2012 12:56:05 +0800 In-Reply-To: <1352955096.6793.1.camel@phoenix> References: <1352955096.6793.1.camel@phoenix> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQl5ZjrlXgIux3ONqwzGbzqRSmC6DSJi8X860h3Rj7l6v2WjWvBTHs5RWRV9l3L/ZLSfp26J X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121114_235613_074561_FB1DF281 X-CRM114-Status: GOOD ( 11.65 ) 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] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Patrice Chotard , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Srinidhi Kasagar X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org of_match_device() may return NULL. Signed-off-by: Axel Lin Acked-by: Lee Jones --- drivers/pinctrl/pinctrl-nomadik.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 238060e..40bd1b3 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c @@ -1863,9 +1863,14 @@ static int __devinit nmk_pinctrl_probe(struct platform_device *pdev) if (platid) version = platid->driver_data; - else if (np) - version = (unsigned int) - of_match_device(nmk_pinctrl_match, &pdev->dev)->data; + else if (np) { + const struct of_device_id *match; + + match = of_match_device(nmk_pinctrl_match, &pdev->dev); + if (!match) + return -ENODEV; + version = (unsigned int) match->data; + } /* Poke in other ASIC variants here */ if (version == PINCTRL_NMK_STN8815)