Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp656690pxv; Thu, 15 Jul 2021 12:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxepayecnYpUSIBSr9DXjga3mO5aPB5NYGLJ/i98feHhpGdmuTl+ahYVviNl/2HXmPAffMl X-Received: by 2002:aa7:dd88:: with SMTP id g8mr9390648edv.196.1626377945577; Thu, 15 Jul 2021 12:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377945; cv=none; d=google.com; s=arc-20160816; b=EvZHtisjPW30QqVSW/irf8Af23GidX6T1gxdIVCPHHiWFU/O6+aA4uW2Gwv+eC8mjP g89OicJUedw2Ee/CjRqJJd5Qgc2FSf5heE0ODG1rpdcn+qpCCMhwu3NDjj+0NmT0V14a lAkRdjcpSe+UVkd6BlnO4CN3s7/qOyVHvKQlWXKzMNLVntt4IR6kYkkZ3aPM9KYjU3ph UypGSsrV1ni336u+zkpx1sxraQxxibfIuEC5XwmU8Wf26uIXFmo1d0g2O2ifyYtNhEA7 /aMm8Gn73s0BNCm8pkR4CPs803unfmCrPwE1G5GSYv7Q0J96akQFETPEnDsY2SmgrwSJ RxDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e/aJKaV99JdzmjsFuMf4B8aV5AB9YYvjh3HpyOg/Cyc=; b=XX6sm5CqCzHWFg5PQZWOclfCsUMe1w6Rnh8THvIWwVyYoyFDWT3mISx4ajoTAPRrN+ hkIJb10EJsK6bCYHSUfBg//ZC81V2Z+VSPCHSLsYKjJ3yZ9VGRG3P//4GgpGaE7ykgvW 0UoDeNEyAeI+kV2YqtCILzcV6Qp0SmblQiRrxScijl1FEmGmOHDR+t39GLsf1XLPYzRo ly9/TYz/Q8fFWUNSmZIUR90D0F6zdennNMGH70a0Qe38ivz1wZY+J3vcEJmyuqFSHBw6 UNYP95AlNe05hKqokoLMJIBeaQk96OxdfT2cJTWnIVcFXMkFNGwQc2Etr160G9jEPyI9 7Whg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K9an4kKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si8476976eds.375.2021.07.15.12.38.43; Thu, 15 Jul 2021 12:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K9an4kKu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343614AbhGOTdX (ORCPT + 99 others); Thu, 15 Jul 2021 15:33:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242538AbhGOTLB (ORCPT ); Thu, 15 Jul 2021 15:11:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5244613E4; Thu, 15 Jul 2021 19:08:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376087; bh=n4e4i6b7pu+S+LOQhnplVOflen9SPRukJwk4NQNpG+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9an4kKuq1ce95vxOYCqGKXQVns9qb2nsxuNm9USzKc3vd6lSsos1zqREVdZ/1kQL S3hwciIuHJa7jgk+9UMjp3hbk+rgaN110R0PCdLkHenNHub7sh52EILLNgOeQ1uKDa 9MsjZ4VDF84I6iU5SzmLJ7poN/TunU0X9AnimlK0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 078/266] net: bcmgenet: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:13 +0200 Message-Id: <20210715182627.934491871@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit 74325bf0104573c6dfce42837139aeef3f34be76 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang Acked-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 5335244e4577..89d16c587bb7 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -423,6 +423,10 @@ static int bcmgenet_mii_register(struct bcmgenet_priv *priv) int id, ret; pres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!pres) { + dev_err(&pdev->dev, "Invalid resource\n"); + return -EINVAL; + } memset(&res, 0, sizeof(res)); memset(&ppd, 0, sizeof(ppd)); -- 2.30.2