Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp639124pxv; Thu, 15 Jul 2021 12:10:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzwxGtN0qxgGdaWVQ5dbH0YAI+5H+yrIV6Sh0qPWCo4NuIknQxwVKcJt1Fq+9ckin7Ewy0 X-Received: by 2002:a17:907:d28:: with SMTP id gn40mr5281044ejc.415.1626376244964; Thu, 15 Jul 2021 12:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376244; cv=none; d=google.com; s=arc-20160816; b=V6ynXy0cQSCf0ttCQA09Tbx+/3eixYfY4yLWmQYCpN1Ca4HRhtSoBE+9rjZBTNwlZu X2NUWWF01GCb2k/PjcxAU10CH90f70ZrUF2Xi7tLWY6f2tlfaomR+l+sUoJxiji0/YOZ cncxCEi0tjOOn5SuYpS7F6Wz6idT57Vj5eR2CXgmH9321xMOBZNdxcjD9JRsjAObARfD XstXuCYYrYSUHaO0qdqbQUJo9IsB6Gl49YqT0x4MURlJVFxj01HGQZgVG3e068g5RicP 5YZqkuspIlnqP17eOQhwbuQ7OWtBaTfb2Y5P2prdXBGRThNw8/bRQxKMq0K+8uzmplrq A2Zw== 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=YKyH84LQfHPFNijQFyfJdWoDsurw99hu+GIbXCaxNfs=; b=UztNUvbw1N+xNDc0Pc7TpTNJ9JSfAUheeXawDg3LTUdjyc+QX+q482URrRGBX8nIIh VfPBFCMjecirOFgT8Nyyj+bzgDIveAJcwpIBFm8WSvUnV/zVky14uVdQp8hRxEuGC3uO rGUzrxibyoHj4hpmVPK5hS6sVZlhtqiHEKt7TtQCMC9yt2UKPesyjahOuR+eCvmKHxl9 HBQpcOKw+7jQrsqExxm0o8xa2JEjWZbQy52NkOB3BDwqoykWBYVuwqRNmk0GJee6SjR2 /Zuv5S7XlFC72UWKrHjH4ceToHWfJaldvvHYL1cThaZQvtDfJPxUJXamprPD94dFA1Bd jzew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cE9RIfR2; 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 k3si9327443eds.281.2021.07.15.12.10.20; Thu, 15 Jul 2021 12:10:44 -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=cE9RIfR2; 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 S243416AbhGOTLg (ORCPT + 99 others); Thu, 15 Jul 2021 15:11:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:35494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242459AbhGOS7m (ORCPT ); Thu, 15 Jul 2021 14:59:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 534F1613C4; Thu, 15 Jul 2021 18:56:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375407; bh=/yC14/bLIYawGdWQBX+LwAKQx0fPeLZdc8PO3V4x3SU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cE9RIfR2ko9AlQYhdoBFRAIEmam3ZrfVCOayeeYmpHTuS/zN0xTgMww0OAg4KfFVB D+jvMLCLmTxuNtZUYtHGk6jpevBCx93Nlh48KoALd+DwF8t4zo/0rQmR47BvUWtu8X 2asrF9w5BR/9cs1eJ8v7AaMi+vqbw+oUIGfVuDR0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 067/242] net: mvpp2: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:09 +0200 Message-Id: <20210715182604.353415174@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 0bb51a3a385790a4be20085494cf78f70dadf646 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index bf06f2d785db..fbee581d02b4 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -7388,6 +7388,10 @@ static int mvpp2_probe(struct platform_device *pdev) return PTR_ERR(priv->lms_base); } else { res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!res) { + dev_err(&pdev->dev, "Invalid resource\n"); + return -EINVAL; + } if (has_acpi_companion(&pdev->dev)) { /* In case the MDIO memory region is declared in * the ACPI, it can already appear as 'in-use' -- 2.30.2