Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp652218pxv; Thu, 15 Jul 2021 12:31:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpZtkojXWxR+pmpBoF3e9rTPyFkryfz/YP6gwuXCb0izbj26REd/8Rfljm7ILoml+dy7C1 X-Received: by 2002:a17:906:4f05:: with SMTP id t5mr7267608eju.351.1626377497882; Thu, 15 Jul 2021 12:31:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377497; cv=none; d=google.com; s=arc-20160816; b=cjGDGKJF5QpVdqQkSG1tidUkLA63JwY4/oZ1tCqPRCdJjk9ipvEYiCGnu2GYVEvxRP BFiu0VMj9ttgCGWTDtMp7ca5CWX5pHNZQ8U/wpZNCKCKHSICFA57sqAihiOqfneua8L3 rAqfzen+cN09MT9dzdioxiRGHxBJ532hLy83zdqVejSxPt84dtug5PmqoCKoYUjyx2VB pDyE5cgQ86QoD/2VFTOycmdmQ5emetltnFYOhvaSUylfz/EuJiEHqmnuE3/XSuV7p8H6 XdThkKRA+eNBunTVhFqw1vR3LgN57Fy2SH+bU6wZFplYrgvjT479thKi7fkArl5rcfrs PBxg== 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=ri9keRFm7nTRHYSVgIkWKa5sAh/xE7SEws07xC5/Bzk=; b=sc9nXqj6dNC4DlPunRtNclTgkA51qX2XDC/B4OllWbBu6uzb5qQ2L39gkPDmwtlB8i xjty0yEG5eIT/amToTm7yisa4tZ9eexymTVEpje0Yy/Acao69LlmciDqem5ooexyr7bc J9Piz52gFcduJzRIuViVrspyhF9Tnsa7WaftOGyKIn/mGw3CfoCp46QossNDH1NPIvDn wZicSBygCCC08JOLpSPe2vuSicuXx7vLikKyyaxznlICUymxZAT3rP3InSwrwOjV3nJW KNtgjZxVisVGNTATeRq79/xV4XcAKY6hOVM5fqOmNh8eBKnRLdnZBMT1HJxeFRP0E01B FhrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T3xBPYld; 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 a9si8288759ejj.647.2021.07.15.12.31.14; Thu, 15 Jul 2021 12:31: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=T3xBPYld; 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 S1343867AbhGOT3j (ORCPT + 99 others); Thu, 15 Jul 2021 15:29:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:46404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243866AbhGOTKL (ORCPT ); Thu, 15 Jul 2021 15:10:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6C32613E4; Thu, 15 Jul 2021 19:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376017; bh=Urdi0RMyDw7osxiomLrzAYzglhIWs81NXDgqg0/pm+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3xBPYldM+N2c6lZhME0lFs9c47AVbFV3+5u2q2h5P1BLUZUbZ7flM3DzkH9txzkm 2nHl8nU4drh8FART+Bx+Tyx1rfoTjAMk7DCBjYVoUWg1fteBiS8qKT+fRN6sJ3Dq6g u+m76DpTV2LpxUeR/LdW7TbY58eYy6Ub8AkK6kVk= 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 091/266] net: sgi: ioc3-eth: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:26 +0200 Message-Id: <20210715182630.240126465@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 db8f7be1e1d64fbf113a456ef94534fbf5e9a9af ] 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/sgi/ioc3-eth.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c index 6eef0f45b133..2b29fd4cbdf4 100644 --- a/drivers/net/ethernet/sgi/ioc3-eth.c +++ b/drivers/net/ethernet/sgi/ioc3-eth.c @@ -835,6 +835,10 @@ static int ioc3eth_probe(struct platform_device *pdev) int err; regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!regs) { + dev_err(&pdev->dev, "Invalid resource\n"); + return -EINVAL; + } /* get mac addr from one wire prom */ if (ioc3eth_get_mac_addr(regs, mac_addr)) return -EPROBE_DEFER; /* not available yet */ -- 2.30.2