Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp629510pxv; Thu, 15 Jul 2021 11:57:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBkB6PdYsKzjDmS4r4Ae/18Tq2EBpZa0j7Li/Xa8bnqU7ouG+wdpxpXXZSzHuQra+vhIZO X-Received: by 2002:a05:6602:179e:: with SMTP id y30mr4142571iox.0.1626375470483; Thu, 15 Jul 2021 11:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375470; cv=none; d=google.com; s=arc-20160816; b=MLRsnT4bE3y3JV8VJRTawTT+ge0lhlWBEbNE3PzC7YI93hg7aAKd41IjsAISoFom42 mCQkzCDYxVfzTHscjjp3p0BGUxdmkCyJlAFXgIfPeIkykFCmfw2wn28rLdEJ3XzlbhBo xHs0jVhNAGG527a0lXHEU6k233YOqNcJZE8ew4Km35LqP7t5ao7x5T1HPa2c/m6jjDa+ m+3beuITF3YvE/ivzLo/MBuR/xlbrIJ4V4SxZ1mS0uCbu05FgeBP518gInYPRYkcK3LC xYUbmP6A5SwfZkhzCiPlzMaDm61N0mwFVaL/55AOms2R0kG4rM/zKdpxy6BIeK7Shp0u qHFg== 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=vY4izWqO/KV4tssFkJlPaPCBD3+K+poFqwA7a3cQT4Y=; b=Pml1rwIVuNkyLUIqLBjCuXnm2nA0XkEjPE5FLEZfh0BUv1AdsVIflJVny5128dpT0R Wcf7ULlnZy51Bm8ZPlm+/s9UkKLbIXH2B9h12qH4GDyXgXyMShtqwyFxrLpRf9S/Tpl/ mjZ06NFoug8IvXONaqIHFVagPe90VE9HeCWgElYWzQMb8q15Ce51d28WJovtiei1rQ3f IeRmDUNTgLRVZJORLS8xzwoHYDxG9QQCEZ6yHx2ZJqNve5N6PA8raH3I6K9yvmrt/nHK 7kZSYE35RRvAxBMdPSgboT1gLnQr40ALDC3FiV8T3ny8FLwMRCMEl7TWeLPpL5ZR3Kkh UXrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qMmmt6Uz; 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 c4si7965578jal.120.2021.07.15.11.57.38; Thu, 15 Jul 2021 11:57:50 -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=qMmmt6Uz; 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 S241084AbhGOS6y (ORCPT + 99 others); Thu, 15 Jul 2021 14:58:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240505AbhGOSwU (ORCPT ); Thu, 15 Jul 2021 14:52:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2596C610C7; Thu, 15 Jul 2021 18:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374966; bh=30GOSRscCV+LcBccfoLXd0HpdRXX0qYf3JIRJoragvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qMmmt6UztfDNs08DCiX3IVq3wBSn5nDmFO8kKUP3MRMDJ3XPF5vVE5utRXm1YlJp+ MYMjP78Q226e9jxpcFQxwhN8GZNizvE265CrxHy79yYOYSPBiEQqBMHj0SCyLe6HXb mIlAX8Cxsa58/UFAaKFtu0QSkAX6UqTI4I1mgIoE= 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.10 060/215] net: bcmgenet: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:12 +0200 Message-Id: <20210715182610.066089604@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 6fb6c3556285..f9e91304d232 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