From patchwork Thu Nov 15 04:52:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1746911 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 9C5F9DF2AB for ; Thu, 15 Nov 2012 04:54:42 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TYrRa-0003SC-GM; Thu, 15 Nov 2012 04:52:50 +0000 Received: from mail-da0-f49.google.com ([209.85.210.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TYrRW-0003Re-Tm for linux-arm-kernel@lists.infradead.org; Thu, 15 Nov 2012 04:52:47 +0000 Received: by mail-da0-f49.google.com with SMTP id q27so473165daj.36 for ; Wed, 14 Nov 2012 20:52:45 -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=cynZgFKsgLSKM4vSw2ztQ2LQCPIYIfXjeW+6pGSW2a4=; b=KGWA3bYaJxUClcydZeFWHNyGbk+hPr/NFXJfNyhK/ooqH67P/w/2bDzMcZbwn2oJU7 gKGTpbBlkoLCy6oR+eY9qcBJh6j0BJwJk5z4J0Ng3uNlbUzpWA7XZmLprWdYFnK9zRg8 RjRbezFXFso4cKguMCgzrL1b6hsDIppAQhmoKL8l0Zh9LksUiHxC/nxNADNVHSi9cjmb pITRb3VAUWy1cLb1rvI9/JzaMck8KJgUG6M8k+Pg6lBdeA4F8rHDKe9Y6vHVKhQMF/ca Ys55XW81h/gEkSDEQDZGMw/4RIpSmAnLXY5Ik6GyMPYnR4nol9VfOVtO2dZJvibozGqX Nm1g== Received: by 10.68.216.73 with SMTP id oo9mr1027984pbc.80.1352955165385; Wed, 14 Nov 2012 20:52:45 -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 us7sm8869478pbc.40.2012.11.14.20.52.42 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 20:52:44 -0800 (PST) Message-ID: <1352955159.6793.2.camel@phoenix> Subject: [PATCH 2/4] pinctrl: kirkwood: Prevent NULL dereference if of_match_device returns NULL From: Axel Lin To: Linus Walleij Date: Thu, 15 Nov 2012 12:52:39 +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: ALoCoQmqpZ8ByTaqfMHeiTV4i9/94PaGjFTvI7/Gx6ptsYET4PX0V6XWjaFiHcbFlEsOhW6j0hm3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121114_235247_087030_8723B577 X-CRM114-Status: GOOD ( 12.41 ) 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.210.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: Thomas Petazzoni , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth 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 --- drivers/pinctrl/mvebu/pinctrl-kirkwood.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c index 9a74ef6..fe885ca 100644 --- a/drivers/pinctrl/mvebu/pinctrl-kirkwood.c +++ b/drivers/pinctrl/mvebu/pinctrl-kirkwood.c @@ -444,8 +444,11 @@ static struct of_device_id kirkwood_pinctrl_of_match[] __devinitdata = { static int __devinit kirkwood_pinctrl_probe(struct platform_device *pdev) { - const struct of_device_id *match = - of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); + const struct of_device_id *match; + + match = of_match_device(kirkwood_pinctrl_of_match, &pdev->dev); + if (!match) + return -ENODEV; pdev->dev.platform_data = match->data; return mvebu_pinctrl_probe(pdev); }