From patchwork Mon Aug 17 15:14:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 265997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 809CBC433E1 for ; Mon, 17 Aug 2020 19:26:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ECD420658 for ; Mon, 17 Aug 2020 19:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597692410; bh=4b12TBHVSCwCKRb00ECpu9pazPTpNjuO50tR6Ppigl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Jy4KKa73WDnoryDcYmZ3dL+3gUo61zBHMogy6mWR2BKGrKA8rSZo4SUUYOfPEztUL KSJWElbhQfOycoGG19/em/n14p75I3HfPB5eJ0Q/up+V9AA4gz8GyfgQO7SG0BcUwL 7wEXc1tXR6mOvyn2qDKeA0kZpK81QA2B+EcS4CG4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732101AbgHQT0Q (ORCPT ); Mon, 17 Aug 2020 15:26:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:37400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730390AbgHQPdy (ORCPT ); Mon, 17 Aug 2020 11:33:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 320FA207DA; Mon, 17 Aug 2020 15:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678433; bh=4b12TBHVSCwCKRb00ECpu9pazPTpNjuO50tR6Ppigl8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h18ahY0wxh0f9/PelFCuCJGc6oT+xzHDNBeGocU9x4puKJJe0u8sA2jxp8P2VQaA8 EEu/YRiWntO1rJ+j6QU1K+D0y3JCnBOUJTwLan9JJkMMc7Wi3XBUvdpUK0zilMrTHk 1DJB4vZLKUp3JLS+hGAJ0YHjyvd24RKmsYWbywyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , "David S. Miller" , Sasha Levin Subject: [PATCH 5.8 333/464] net: ll_temac: Use devm_platform_ioremap_resource_byname() Date: Mon, 17 Aug 2020 17:14:46 +0200 Message-Id: <20200817143849.738305910@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Wang Hai [ Upstream commit bd69058f50d5ffa659423bcfa6fe6280ce9c760a ] platform_get_resource() may fail and return NULL, so we had better check its return value to avoid a NULL pointer dereference a bit later in the code. Fix it to use devm_platform_ioremap_resource_byname() instead of calling platform_get_resource_byname() and devm_ioremap(). Fixes: 8425c41d1ef7 ("net: ll_temac: Extend support to non-device-tree platforms") Reported-by: Hulk Robot Signed-off-by: Wang Hai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/xilinx/ll_temac_main.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c index 929244064abd9..9a15f14daa479 100644 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -1407,10 +1407,8 @@ static int temac_probe(struct platform_device *pdev) } /* map device registers */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - lp->regs = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!lp->regs) { + lp->regs = devm_platform_ioremap_resource_byname(pdev, 0); + if (IS_ERR(lp->regs)) { dev_err(&pdev->dev, "could not map TEMAC registers\n"); return -ENOMEM; }