Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp651641pxv; Thu, 15 Jul 2021 12:30:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaEqsRVazgJeZmKUzUaNGjQZF4yrMQgDm8hxKwN6/tzYJrRfE2lWWXBCaj+diXK8F+bIDl X-Received: by 2002:a50:9b06:: with SMTP id o6mr9423483edi.284.1626377437756; Thu, 15 Jul 2021 12:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377437; cv=none; d=google.com; s=arc-20160816; b=TxJpbLA1ouku4u+aQzfGy+C8NtFGpnPKWbepJDC/fX2gNMrO75aIXyKndHVMOS6uKx LfOL6vsiEwDJQEXzQpYh8wrglmZiQtSZpfHsaOj7STcrJOhaDM+hnCrtXdnfDCItzMTu jD7VbZO/4At5nJlLUcL9+B2hvxowcETICpVmKVf0VoTTqSn6Gxgf+PL+a/qau9zcT3CU 8Pp3u7rITzHRCeOgfMIJlkKUBSIDZI5V+kChyGJseW9R7S1XU1acdBm+YYRYMBYd8FIn ReTi4en0CqndlfTNdfRR41w8WNYZ04cOXEy9vEAs2JqWonES3KLlQLaq1aw6pWU84nIx zrsQ== 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=jGFF2sR4V9HMs8gmK8gpQc1kcRW7lsPDeCu3Y7aZdw0=; b=QcnZRJJpIl3HJWhdu0+eKVsg9ouxV0m5nOV32KAT1L+j5T0eYUAYw66GcePOXW8B2k D44SnhNLJCGKvW84fglLylFeaAonrDBHpbirP/XQx14xKgaqgdrqAC3/c1tRFjTLniM9 QlTrbNG2hWTfMzym8zhIF7ZgVq0tR3jPJgRENjhznYiUEEnDxdnP3Ms/j5jrhE6f9RlH ubnSvHjDd+9asV8+OE2/W2xT1W1uUlpyCTuckzQaL/9WgYLf9lRPMkAaK4uW/ovBjGEf R0E9wxX8REWznf5eTyVpI3lU8oSf5ZDFNYRKu852O4/8hp+Ol+H3iKvhiuIMSo+KriuB JNoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rEF1I1MF; 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 n3si9061675ejl.4.2021.07.15.12.30.12; Thu, 15 Jul 2021 12:30:37 -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=rEF1I1MF; 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 S245378AbhGOT2D (ORCPT + 99 others); Thu, 15 Jul 2021 15:28:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:45628 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243735AbhGOTKC (ORCPT ); Thu, 15 Jul 2021 15:10:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5AD15601FE; Thu, 15 Jul 2021 19:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375986; bh=1xZbz8SnTsF8urNq0nGOSLHQcaxDLJdxa782w9S3ugk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rEF1I1MF3oDxSDB9WW/tWw+Yqg9IUaRRZh71nzi1mmpVmjOtQ7VGfcjqEtgVJChiH qH2aqg+FS+eeExGyXPRPjKZF7YZXt+klCFL4UO8RBvB5C89YKiTpTIN30/UoQ4DIcu I6HytYAExAsO3uXoWWpK92Jj1sHNCUM6gJklkKmQ= 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.13 079/266] net: mvpp2: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:14 +0200 Message-Id: <20210715182628.129988339@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 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 b3041fe6c0ae..42cc27ef7378 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -7387,6 +7387,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