From patchwork Fri Jul 7 06:59:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 785379 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x3lq603nFz9s75 for ; Fri, 7 Jul 2017 17:00:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qEQYhEqm"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0yC7wOxzQSsr1C8HZg7bCIn0gvZCVse1npLPqpTF4ik=; b=qEQYhEqmsJky7A KMc8dymPM1jpVoTZAa5l4URefoNHKVkiwMhMRsgOMLdt+hswabhE9VwzDdvAf8D1HUQfwmeAmfzG5 RsZDb26BU4GPSKFCKorrIbkxWfyadWnsCKTSkFyISs7h+7aPKh94uwy40vHlLtFFXWX++3iJF7L00 M76Q9M/vDG5G3pKJEtwUR3XioxX6RPZAxRfMGrAr0LNEa0iu7jpZdx1C/Y4j7ludHRAeevx0XzymK pIr+nsyZp7x9Pf3mVqXKYTiU4g+Hu/4waiLJj6DUJdWkVhg/GiEhFQ3YI7KijsE5SwR7Gs1Zqk2Fm wqnNG6ojAFd7ZaGla35A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dTNF4-0004a4-T8; Fri, 07 Jul 2017 06:59:54 +0000 Received: from gateway31.websitewelcome.com ([192.185.143.43]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dTNF1-0004ZG-C7 for linux-mtd@lists.infradead.org; Fri, 07 Jul 2017 06:59:53 +0000 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway31.websitewelcome.com (Postfix) with ESMTP id 299A019BC0 for ; Fri, 7 Jul 2017 01:59:27 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id TNEHdBST8FnrPTNEHd3fj9; Fri, 07 Jul 2017 01:59:05 -0500 Received: from [189.152.152.176] (port=60220 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.87) (envelope-from ) id 1dTNEc-002OVS-T5; Fri, 07 Jul 2017 01:59:26 -0500 Date: Fri, 7 Jul 2017 01:59:26 -0500 From: "Gustavo A. R. Silva" To: Stefan Agner , Boris Brezillon , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Cyrille Pitchen Subject: [PATCH] mtd: nand: vf610_nfc: add NULL check on of_match_device() return value Message-ID: <20170707065926.GA25776@embeddedgus> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.152.152.176 X-Exim-ID: 1dTNEc-002OVS-T5 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.152.152.176]:60220 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 62 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170706_235951_495541_2AEEA033 X-CRM114-Status: UNSURE ( 7.11 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [192.185.143.43 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gustavo A. R. Silva" , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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 -ENODEV Signed-off-by: Gustavo A. R. Silva --- drivers/mtd/nand/vf610_nfc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mtd/nand/vf610_nfc.c b/drivers/mtd/nand/vf610_nfc.c index 744ab10..ca0ab96 100644 --- a/drivers/mtd/nand/vf610_nfc.c +++ b/drivers/mtd/nand/vf610_nfc.c @@ -674,6 +674,11 @@ static int vf610_nfc_probe(struct platform_device *pdev) } of_id = of_match_device(vf610_nfc_dt_ids, &pdev->dev); + if (!of_id) { + dev_err(&pdev->dev, "Failed to match device!\n"); + return -ENODEV; + } + nfc->variant = (enum vf610_nfc_variant)of_id->data; for_each_available_child_of_node(nfc->dev->of_node, child) {