Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp707955pxv; Thu, 15 Jul 2021 14:04:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6q8MmSekUiVCPzHnVXCu/KCcjZb7PS4kOD4Equj8LJRpZUW2ak4am8j3wXI5NNnxtfNtj X-Received: by 2002:a17:907:10cc:: with SMTP id rv12mr7475076ejb.339.1626383047825; Thu, 15 Jul 2021 14:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383047; cv=none; d=google.com; s=arc-20160816; b=Fn1w6yb/07z3k28c3TizL4rT9MLrNOb4vhpkxSQQ14e2yZaGAPD2mMZjOM0t1V5IQ1 MQe+kN2gt/KbfsDkjc9mHCCaKHJ8E19zi8P6/Mdv+nUmrSLjCkZRWjHhEWyACbAzlMpo uwab3wrLZ5we6GWKiHzm7vjUY0GVUHfYNfkNm5ZoySuJIPawJ5wiHl5wMeTHCGXmYKnt 6RxQ9y2ye2XoMRnGQQXX7xUtbEMqcXt3pP6/R3HRB6Znm0SgQhRd2v81gb3qcOMYyxJy 1ePyhSvMjr64Fa+0pe8Z5zWu/dCs1g1HlrEsG7K2My4mx1UBNtleu6gTl9zgGWygZhVK Hm2A== 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=mS0uVEvLOuolFoLi2ZsCNMoobQDC99cGB1+HIq6mJavf2Fr7KGdQNqw7FbHAZolAlg TvqPsxxWLfl+t3WxVPT+gcyy4h1vCxmpo8Y42u2H4CWszw3NatX2b0tIvlzc4VWmV64z 4C/gx0SKPKEGjTKk0NBkkYB8hO9pOvWWGf5af/Xd2c3fDxtg7IHrAywhHK6EPduLKoLX SdfOowmSC/aWid3qal0JA0/8FYOTsIxUgAR+40y0VCZLTLJho7x33ad2Q7P5SYB0RvFG HlA5vQaN1wyky0KGhta6ZbIqljk7ZGudKGGaVmDyRZZMdAHRlBLYova0fupGQryn800w q/ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xwFpUAdL; 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 lc12si8566104ejc.671.2021.07.15.14.03.42; Thu, 15 Jul 2021 14:04:07 -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=xwFpUAdL; 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 S244097AbhGOTOL (ORCPT + 99 others); Thu, 15 Jul 2021 15:14:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:35104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242620AbhGOS7t (ORCPT ); Thu, 15 Jul 2021 14:59:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49AAD61158; Thu, 15 Jul 2021 18:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375414; bh=Urdi0RMyDw7osxiomLrzAYzglhIWs81NXDgqg0/pm+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xwFpUAdLCT98+dqH3rt+SC1N8+dpV/cguu359rQdKFOmw/9OmzYhw7T/L9Q1f7BZ7 KxBlTz+UzvmlwZH5XmUwwDO4XuZGZK8VrgFJeXYrLD7S3gWcs/zOWUfrEk97bmZcfo CPW0pt2NkVG1eCM+DeEZZGJqO3Nd9/1jMO3EMIEs= 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 078/242] net: sgi: ioc3-eth: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:20 +0200 Message-Id: <20210715182606.644790006@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 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