Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp708750pxv; Thu, 15 Jul 2021 14:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIroMMjsAMOUZZrGxnAQPDVPTTXLjzzieKixgcNHExptVE67y7qcWv/KO5zLQJM5M9/UWK X-Received: by 2002:a05:6402:13c3:: with SMTP id a3mr9740721edx.187.1626383119029; Thu, 15 Jul 2021 14:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383119; cv=none; d=google.com; s=arc-20160816; b=Y6J47MapVbiEISmWvM//Xi30Y8gBSF1edizwK02q5HFLPpaySn4j2v7DT/XtHyZ2VZ H78CbKkRp8hOu+wu7jCeIteuG7iBb/6bRt2ETHEwaTly7eutwQbiRN4gThhtptbAjXUt nTXUDaG7wt8XOvUBGES/QGwKleA65/c2An7YoLLOwLp9kctiDyO5xQx6idtXnXT/Pw0R SdyasLqtAmv+cCkULy5144nJpAyQmL3msBDggyUQjKTmKyTufa0waUlJBTRl0nvDD0fg yzOKTDxHj9ux90Sf6sjK7wbpnOG1Nbf1HiZFu00Qc6QHxys4TArfCGaDqYsrO44zJoys dvlg== 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=WAUqklKE4QAFU5pl5zCOFDmU61BftbTKHBc89WaB6bYJvHU663PnGwv5SoJra100hp Jmi6cqRpzpJ4Mu0mJn8ExPJ4fM9o2oRSDbZszzkX0rYiflXlpmWJa10gu35y4NCriYCl X/K/SzQiA8hYoNyWn+eK6PqsNMZ0edbohUDBGERzEEqPgexZjpG2l/cguYcGKylZmmqP OIDmMskNRSenk3kj4vW5Dlexhe2xDltOjp8I0bxKa1831Hlq9wANQx/fRq3In9bV2NO1 SMz7vweCx44ZJkSEOA5rwrnyObhpWXLhpZje2/I5foTLmAyBYKRu6V041ycDAeWQOq+Y pRlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fSRGmnxE; 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 8si10465499ejx.637.2021.07.15.14.04.55; Thu, 15 Jul 2021 14:05:19 -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=fSRGmnxE; 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 S244807AbhGOTPP (ORCPT + 99 others); Thu, 15 Jul 2021 15:15:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:38830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235298AbhGOTBq (ORCPT ); Thu, 15 Jul 2021 15:01:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E85D6613D8; Thu, 15 Jul 2021 18:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375513; bh=n4e4i6b7pu+S+LOQhnplVOflen9SPRukJwk4NQNpG+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSRGmnxEnZJK/64nCZdOjHZACb2YMufUQ3KrVN9q44A1ExlwpO6TWvp/xh+oW3nZV bKDYPRJXXtwDlTo1bW0Z016L4cfmN8DLOMp7KscE5mO+Cek0BwZWn++r/L1sIk3ePM qa1tnTZtzwByncHJ3F6641OQDnS3hwL8vXiQMhos= 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.12 066/242] net: bcmgenet: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:08 +0200 Message-Id: <20210715182604.169441736@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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