Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp398487yba; Mon, 1 Apr 2019 08:32:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzDV03Fj8Cjam6LWEizAvyRwRlveydyT9HORcdY9Goi/NT1AmUfR1RH8Bk/XJ5WZf1Lldq X-Received: by 2002:a65:51c8:: with SMTP id i8mr11105503pgq.175.1554132743867; Mon, 01 Apr 2019 08:32:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554132743; cv=none; d=google.com; s=arc-20160816; b=Ujzbs0+rG7Wa1SkKyTrWGDnaNM8sB9ib6bOj16BgTr6KPuLOSXSCpkByt0Dmzh/T8h Cs5qQMIuYRhS3MdPK+iqgo8vVualUxihumMAK4iU8uKy9YtyX461i69zJ0ScxfrOgORn J6Kz7JWss1tX6vFMRfe+MnUJTdySaqqtaKWYENLPRR6gCZrYo9TeNgfVPpwIwiYFaP6p vz8/zvF3lR05u9lKbesHBqGU+9/+czQGT6gW4Pg4+BnaWYXJoa7HOmsTGbdgLx0FvnmR dl4wtSW/AWd8o7hd0rUSqp7+WXK+SOGZg5BmWjVnEgWH63Tm1yhbDOusJBMsaCiCQoSX /e7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=cVS760qEF29Aa5SnIlDZTZe5MN7JhtT0Ux5dsNxqzJU=; b=RdULAINtd5h19WoDz8XlmxEAzk5lHK3s160C1s3ANCfOC/8ycn0GNPz8RODnfLIWF2 /RpAIWSXMbS+g0CWowCOFQDFjxgflHKctNGtH01ziAQVqqHUifN4AQhALN9g7QOEE7J1 8czk4WhHtbWL3OKhTibYRw/fGx/mk5w3l2RCcTXPxvKVVEPwIozPRTLbGIcIjEEANAUR lk+Q+bRJbZm4EAoxx4S/Aw22c4hHGCAUkx+p+QmHN6QrMO8IuDF+mR/GFr+UZDtWDIMO P1AyFKlOox3uIEDmorl73FPlA33Je9Illh3vpzlc6CbyRpFtgy/n7OgYWJoEG4CYErno x4sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x15si9052509pgq.194.2019.04.01.08.32.08; Mon, 01 Apr 2019 08:32:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728629AbfDAPbB convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Apr 2019 11:31:01 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:41176 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbfDAPbB (ORCPT ); Mon, 1 Apr 2019 11:31:01 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 2B8D7281FCB; Mon, 1 Apr 2019 16:30:59 +0100 (BST) Date: Mon, 1 Apr 2019 17:30:56 +0200 From: Boris Brezillon To: Miquel Raynal Cc: Aditya Pakki , kjlu@umn.edu, Stefan Agner , Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: rawnand: vf610: Fix to check for NULL pointer dereference Message-ID: <20190401173056.17604b54@collabora.com> In-Reply-To: <20190401172651.158c05fe@xps13> References: <20190318232434.9246-1-pakki001@umn.edu> <20190401172651.158c05fe@xps13> Organization: Collabora X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Apr 2019 17:26:51 +0200 Miquel Raynal wrote: > Hi Aditya, > > Aditya Pakki wrote on Mon, 18 Mar 2019 18:24:34 > -0500: > > > of_match_device can return NULL if there is no matching device is found. > > The patch avoids a potential NULL pointer dereference by checking for the > > return value and passing the error upstream. > > > > Signed-off-by: Aditya Pakki > > --- > > drivers/mtd/nand/raw/vf610_nfc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c > > index a662ca1970e5..946abbb275c3 100644 > > --- a/drivers/mtd/nand/raw/vf610_nfc.c > > +++ b/drivers/mtd/nand/raw/vf610_nfc.c > > @@ -850,6 +850,8 @@ static int vf610_nfc_probe(struct platform_device *pdev) > > } > > > > of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); > > + if (!of_id) > > + return -ENODEV; For the record, this can't happen unless you have serious memory corruption issues since you reached the ->probe() function (which means a match was found before). > > nfc->variant = (enum vf610_nfc_variant)of_id->data; > > > > for_each_available_child_of_node(nfc->dev->of_node, child) { > > > Applied to git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git > on nand/next with the title changed to > > mtd: rawnand: vf610: Avoid a potential NULL pointer dereference > > and a space after the return statement. > > Thanks, > Miquèl