Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbdGGHmR (ORCPT ); Fri, 7 Jul 2017 03:42:17 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:9247 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbdGGHmP (ORCPT ); Fri, 7 Jul 2017 03:42:15 -0400 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Fri, 07 Jul 2017 00:42:13 -0700 Subject: Re: [PATCH] drm/tegra: sor: add NULL check on of_match_device() return value To: "Gustavo A. R. Silva" , Thierry Reding , David Airlie CC: , , References: <20170707061119.GA12563@embeddedgus> From: Jon Hunter Message-ID: <27ec9e14-f5da-4240-1158-e3c9af4d6f10@nvidia.com> Date: Fri, 7 Jul 2017 08:42:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170707061119.GA12563@embeddedgus> X-Originating-IP: [10.21.132.162] X-ClientProxiedBy: UKMAIL101.nvidia.com (10.26.138.13) To UKMAIL101.nvidia.com (10.26.138.13) Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 928 Lines: 32 On 07/07/17 07:11, Gustavo A. R. Silva wrote: > Check return value from call to of_match_device() > in order to prevent a NULL pointer dereference. > > In case of NULL print error message and return. > > Signed-off-by: Gustavo A. R. Silva > --- > drivers/gpu/drm/tegra/sor.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c > index a8f5289..ca3d9b1 100644 > --- a/drivers/gpu/drm/tegra/sor.c > +++ b/drivers/gpu/drm/tegra/sor.c > @@ -2538,6 +2538,10 @@ static int tegra_sor_probe(struct platform_device *pdev) > int err; > > match = of_match_device(tegra_sor_of_match, &pdev->dev); > + if (!match) { > + dev_err(&pdev->dev, "failed to match device\n"); > + return -ENODEV; > + } Given that Tegra always uses device-tree, I believe that this cannot happen and so this additional check is not needed. Jon -- nvpublic