From patchwork Tue May 19 14:14:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Hunter X-Patchwork-Id: 473924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 14B7514029C for ; Wed, 20 May 2015 00:14:47 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932659AbbESOOp (ORCPT ); Tue, 19 May 2015 10:14:45 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:9237 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933021AbbESOOo (ORCPT ); Tue, 19 May 2015 10:14:44 -0400 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Tue, 19 May 2015 07:14:19 -0700 Received: from hqemhub02.nvidia.com ([172.20.150.31]) by hqnvupgp07.nvidia.com (PGP Universal service); Tue, 19 May 2015 07:12:47 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 19 May 2015 07:12:47 -0700 Received: from jonathanh-lm.nvidia.com (172.20.144.16) by hqemhub02.nvidia.com (172.20.150.31) with Microsoft SMTP Server (TLS) id 8.3.342.0; Tue, 19 May 2015 07:14:43 -0700 From: Jon Hunter To: Linus Walleij , Stephen Warren , Thierry Reding , Alexandre Courbot CC: linux-tegra@vger.kernel.org, linux-gpio@vger.kernel.org, Jon Hunter Subject: [PATCH 3/3] pinctrl: tegra-xusb: Check that of_match_node returns a valid pointer Date: Tue, 19 May 2015 15:14:23 +0100 Message-ID: <1432044863-2035-4-git-send-email-jonathanh@nvidia.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432044863-2035-1-git-send-email-jonathanh@nvidia.com> References: <1432044863-2035-1-git-send-email-jonathanh@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org of_match_node() will return NULL if no match is found and so check for this before dereferencing the pointer. Signed-off-by: Jon Hunter --- drivers/pinctrl/pinctrl-tegra-xusb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/pinctrl-tegra-xusb.c b/drivers/pinctrl/pinctrl-tegra-xusb.c index c61594066e26..0030cfb9c0a8 100644 --- a/drivers/pinctrl/pinctrl-tegra-xusb.c +++ b/drivers/pinctrl/pinctrl-tegra-xusb.c @@ -899,6 +899,9 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) padctl->dev = &pdev->dev; match = of_match_node(tegra_xusb_padctl_of_match, pdev->dev.of_node); + if (!match) + return -EINVAL; + padctl->soc = match->data; res = platform_get_resource(pdev, IORESOURCE_MEM, 0);