Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp630026pxv; Thu, 15 Jul 2021 11:58:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8xLKzgv5ar4TozAHcpdtVG0rVU4US+/JBB3KYtpv3DDiIrTbbm5cyPKDzDao1zVEkwdqz X-Received: by 2002:aa7:c857:: with SMTP id g23mr9036954edt.100.1626375521373; Thu, 15 Jul 2021 11:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375521; cv=none; d=google.com; s=arc-20160816; b=w64adMdtyn2iww7Dy3xJBV1vp5zrXYxp4aOk1nOp3OSFOkk0kJaSKc/Dyxby/AG93H ZGjPXa8avWm2jqtvV/FCiusQUaq5kyZPYH8NzmeStBUJsBboBG52dvAmrpvWgpdlDUok ZC9Z8ULEWUjaM9kkjfhWEJkdm6yCPmDgaWcS7gMv1+0e82VJM3UFEkhTCqtsj9Umm7hi s5MH9x2sDPBUlAmdXw+erdfBqbqDTSvJguAsQ7h0y5M+PsJy3H1Y2vgdaYkeq87Z9cTG 3AJPscQp8vuJlvkZ+pso8YcHon1N8F2xyXOnBB+5Ivu34qZLI/EG5tz2UHWqEp6Kxa9v bjEg== 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=QpGuTPXa7fm+IJ1eL/OsbI+F8MvQDImWf2hbEmn9VUY=; b=NaIeLFymsr1Jr9Hubg+jXubsDNNDdTmGGsVNhT4NulYsup7eT25icYYMsi3K3G9y6h 9X7IFrVEN0N2Bfk5RzUuM2/9alE5o23j7UUmT/2TcPU2FYnUxSQGYQn/leLtmjMu1nRz PdlMdQ7yH9vUce6OkQ/6+9jjWDb5ZOQK/g41YY2L8fWctbtTfn6Ux4r4r54WO12lXGGn TPC1vdPI8Tihzbpzj6ikMVgn+ZUPrZIbN7oF/p4N5CxtByAGIYjftUla1tQJsw2mKTMC BqmB91BZ4j5MZ+fjBzACIVfC/IW5J2/dchstxiIMUlx6YtEOr9JjHz1oC+MuPMuL5p8b 6Fqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jWa3/Nuo"; 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 my47si8842071ejc.645.2021.07.15.11.58.17; Thu, 15 Jul 2021 11:58:41 -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="jWa3/Nuo"; 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 S240366AbhGOS67 (ORCPT + 99 others); Thu, 15 Jul 2021 14:58:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:56094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240007AbhGOSwZ (ORCPT ); Thu, 15 Jul 2021 14:52:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C6A72613EB; Thu, 15 Jul 2021 18:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374971; bh=lxynscbsCQDk1myZDrdth+KqETVGa5AjuevgsM1C6+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWa3/NuoxL3WBqzTwh40qfB4bgYUyxm5UaiS3balspfjPgoWB+puZYzSlIyZsd42u BLYuKsEr9A0Rj1l6G3KVKOtKvrvjLDui+NwEIM1WG3gsQBdFinicOKOsNQ4lR5YAlA ALmXChF+WfjeNYinjjuCAz4FQzjn+8diWC6jgH98= 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 062/215] net: micrel: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:14 +0200 Message-Id: <20210715182610.406018281@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 20f1932e2282c58cb5ac59517585206cf5b385ae ] 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/micrel/ks8842.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c index caa251d0e381..b27713906d3a 100644 --- a/drivers/net/ethernet/micrel/ks8842.c +++ b/drivers/net/ethernet/micrel/ks8842.c @@ -1135,6 +1135,10 @@ static int ks8842_probe(struct platform_device *pdev) unsigned i; iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iomem) { + dev_err(&pdev->dev, "Invalid resource\n"); + return -EINVAL; + } if (!request_mem_region(iomem->start, resource_size(iomem), DRV_NAME)) goto err_mem_region; -- 2.30.2