Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp627182pxv; Thu, 15 Jul 2021 11:54:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyomjzya55LLpD0Klboh1IZ4stnMVqR98WWLTfneKH8+7z35KdCxxg+n0cX9Dw2mavO37c1 X-Received: by 2002:a92:360e:: with SMTP id d14mr3631649ila.106.1626375263927; Thu, 15 Jul 2021 11:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375263; cv=none; d=google.com; s=arc-20160816; b=ldZJT4taYYGBWPu4u+IP8/tUVF7JgzfA3vWSfR4XIoJIo1wEzglL6YPHv/iaQUTBUX WX+5VIG2ppGhg+StadtL4yDvHGJmVaclHKfKlSq210Ew0j+YvrpuSUR3S92tDdAjedYx 0QEvzIRQuEjGg4tsjsj9K2a+j+HmFbAEJeyVz4u51oUGEvtmWNLspAQxQRRZWuQt1pXe /0X2mA7G9jozjCMZm8edX7+6LheyvpL8eGdJX0sw6IYEdqBB6p6xUgjYMnrmTSfWwPK9 6oyXS77Q2n61OSZLfl93wsxtjN6QlQQdCYVfEcaXRwhaiyTW2MYwUDsPVqwh7p23P+TC k5pg== 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=fjstbhGjxVjGCP/nVk7EFN2cikVeG/48W2njBidOZk1qMzY6KXS00CF6h6ydkAxl+x K0M/VTc0j7+i+ahJS9G8Ex2Usl4eGzadTOmeUtILkwMc+gj7KRP9qH9iwK6nGrzXs445 8grDUm2W78DhpXBeIhDDwfyoWUtSNS17m+O98BSc0EFoq1PDs6H08fUysrH6XUQvPXi3 86xAXdHxIFD9gUfZ+ghgdnInL2EKdcu1ZTX4MlnnXA3ccI823+UI+M6Cs5T/9W/58bur wNiKZDTScAidk2zCXjKHrq53QvGGfTKmUgHLRM1KKcDYfEAU7en/ZVlepEmgRXvddtYX FAhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ySVTlL+c; 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 t11si7733953ils.106.2021.07.15.11.54.10; Thu, 15 Jul 2021 11:54:23 -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=ySVTlL+c; 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 S238211AbhGOS4U (ORCPT + 99 others); Thu, 15 Jul 2021 14:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:53266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239847AbhGOSvF (ORCPT ); Thu, 15 Jul 2021 14:51:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7DA90613D0; Thu, 15 Jul 2021 18:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374892; bh=Urdi0RMyDw7osxiomLrzAYzglhIWs81NXDgqg0/pm+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ySVTlL+cP9fLPpAJkMhLHV5mKR/cYa42qaecyGNRk8Pl3t4cnAYRki74fZaS5lqbB e9zLvAN9246dDP0u2lc1Ik/mSlSsABKuDC08MZW6Hj/YjDM0xsbD37PJEmtASWCRXW i2hQ9FgrnOCudE31IJFHgtBwYB6nxLXvFgExcEdI= 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 071/215] net: sgi: ioc3-eth: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:23 +0200 Message-Id: <20210715182611.998259495@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 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