Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630193pxv; Thu, 15 Jul 2021 11:59:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE0zIi51H3HaqGLMjvA7TI+78JH1xwYaUgyW6Avabi0oyGxiqstBc0j1XzgszJKVU+81a6 X-Received: by 2002:a5d:9b14:: with SMTP id y20mr4234974ion.8.1626375540078; Thu, 15 Jul 2021 11:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375540; cv=none; d=google.com; s=arc-20160816; b=MvzaLqaQOTpg2lSzyAIZlJV1kHoRLhk5alMa4ZaGmZjP68+C/9mCgicO23RaSj1Q+R PO4jqcELVsTDO/bTOE047GzZjWCvUmV7Qf0844qloD/zkUyCfx4OvHR3OQzZU2X2iOVG YjB7SSF0KqA0mySIa7T3vLSGxx8J/6l5gVtjZ/B2akLQfA6zqzjediskuK9XxjMQlTkz txqaioJyhbPo99SoIRw4bXZN0larnk2bKC1uGreb3Ik86Z/T7FfG3A+hb130ds3H0fVO iviUU8UGNNZJgIhvRPSozxwBGKhlK8xU8EwfTZ7XLk4cAgeOSi9r9GFaOmBrhOYU3GXn RZlw== 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=J4N3njL5VVw79T6L3Fw1eOeRJFLnL7/eA88/XuaE7hg=; b=D4YnrlSvB+EsPg26Jbb5uOqKttAJG6i0mwlbVz2vtaNP77Q2NkknbAlJfslmf8rsIy nZDH/Ff/2uMBorb9VLD3VTqW+YjcnyqmUN5NUP5alF5AZ9sQL12fx4VhKqeCPhpH+WmX kmrdRO+RMOWpVyXxVYXsKyLJClFdKkBTMVnYSg4u99LdPrJUBRQM2pkRthItRvZsaKT8 7kom9qWLPEfGy6CwD/2x5IuRAA61pFHE8jjNocoSF7KRGDFDCwQCTrd0MKX09UF5EQYS YcP47AOV7sEwjlt0KIlcuvAA29hY6cmCuptGGpP68aS87VPsnvDDxiwu/XYrgKFwWJpf vTJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GVLMaKQF; 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 j23si8296132iog.79.2021.07.15.11.58.47; Thu, 15 Jul 2021 11:59:00 -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=GVLMaKQF; 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 S241616AbhGOS7Y (ORCPT + 99 others); Thu, 15 Jul 2021 14:59:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:56036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235622AbhGOSwW (ORCPT ); Thu, 15 Jul 2021 14:52:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75712613CA; Thu, 15 Jul 2021 18:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374968; bh=5aZaqVlJN1tEwONIPTLplF4PD+U6nHazFadxaYPimhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GVLMaKQFepwsdgL3Z9wJ69X/IQAz3vWmrfs+o3PbKvkdys10IMo1M9kBnJ13RGhQ9 a09iXbrC3a645lhchOoBVtippugBxV74q4FaZzP4/DBndrdi8b1TXCTfLRUZeALQ9S 7B5uLMHRRTbR6EK9O3RfIQpm5STSaMrFmtqiIacM= 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.10 061/215] net: mvpp2: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:13 +0200 Message-Id: <20210715182610.238247147@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 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 a9f65d667761..ec9b6c564300 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -6871,6 +6871,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