Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp639588pxv; Thu, 15 Jul 2021 12:11:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwKhAok7lubk3xOvn9rpMtrvqOpNn4+cfLiVVrpfFNiY3N5ILbeulje5ngCPxhcyrWHcZe X-Received: by 2002:a05:6402:214:: with SMTP id t20mr9422668edv.20.1626376282170; Thu, 15 Jul 2021 12:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376282; cv=none; d=google.com; s=arc-20160816; b=0Bymdt6aMmHRxXbFNzZCw4OnfN2xdqLAjwmawI+KaL+tDPb4210B8xzT3iFA1+zR3e FEw+gkCOBNdDJzXkTLDhB9Apw4ZKxO4YtczEDxWDv9te5Y1Rrt5AsaszrWSV+mLgfnZ/ pR3EsVWOJgR76CmUCkZDj+D/wDymcWkETp/GwrjZL1S5B5xbslu09KLjf/95Aa566oNv uGY1dK3B0GdXi9btfAN5Pgf1Fmc/OFRCNzmx4zE/0LD3xmUWxAEuJ8ilw0Nklaybx/lK KyiLrWqAfF3kUf6NbcpWuy4g0yRqTNriR4oggtAavhVoWcz1myCRj6MpZK+2VTMESnE7 sr7A== 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=bro60W7snhxntDE2TZMVOzOG57Rvc8Y0/0lMo+ZhYEQAiga5Kw9VSNEnxzkCjQwx+5 TdFFH/FdtHh4eZ//7Su5k+W0xbkPmDTuJ8S9p9/gFy53RqdFFCcX45Zy0Gssc69jsC/m JV30lrvSOlUpH8agGNykmo5wTOa6TESXCJwGEO33i1rRnq5RG/P5xHcexIbdXEpfNFqn lOmsQo/vE6MNkphYaIXb147wb1fw/eHi1keGIPVBI97vtPR6ItUo2fNMD5+1lI/d0Buo g8L3udPbBd6/Sa3TWK7uX7f93lmp5LO6qTA5Pkuq3tDS1AbbeHmAyAPRvQS27zijy+AG z7KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RuE3JRTD; 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 d26si7790152ejc.620.2021.07.15.12.10.58; Thu, 15 Jul 2021 12:11:22 -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=RuE3JRTD; 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 S243869AbhGOTL7 (ORCPT + 99 others); Thu, 15 Jul 2021 15:11:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:34728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242949AbhGOTAG (ORCPT ); Thu, 15 Jul 2021 15:00:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EB40C601FE; Thu, 15 Jul 2021 18:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375433; bh=lxynscbsCQDk1myZDrdth+KqETVGa5AjuevgsM1C6+w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RuE3JRTDFefejRo1eSvEaVPN1miEqFOVoy/vl8Zd24wb5mRdjVlwTCmqqe0pvqvj2 12fX03wIJdryI/Y1/wYhCt/j+j0bRjeMd/TMUjewSFNyLS2nQKFDZc1qEl6961CYhv P+R7iAcOBakoNgW/Z6/e3roofiUKQReJ1PQiriSg= 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 068/242] net: micrel: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:10 +0200 Message-Id: <20210715182604.529347767@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 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