Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1852874pxb; Thu, 16 Sep 2021 17:58:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcvX6adNd4gid4x5hK28INIu/EEfRSBe/qV34GAOnFEtG9vItKSrdRNnBtQ+rnO0E2bAFU X-Received: by 2002:a05:6602:2219:: with SMTP id n25mr6387136ion.185.1631840324856; Thu, 16 Sep 2021 17:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631840324; cv=none; d=google.com; s=arc-20160816; b=U2A29ck/2OIFt7K7YRber7iHHRN8fcdLV736+TREjKn0omspa8Y7PJ0WLD5gHVqEZG GBEFwT3/1eY4/4fSmGD1N7okd5gbsYx4GJBd1HKWjyaWrel95sEel+GKVRGPHG5Ti94o zmfmrNE5csr6ryBaeyzRDaIhpIUzxlyz4B4crEs3Sv3T29E/MtJUieepKMjLfN5UErDn BdmfuEl/rVnSY4sySCmFHYSYN1UO3xhOlFplg+QjZ06dmcWPVdypMkVZ10BT+TdvaKs7 UE+V1NW+91t12cckSTRibiWHFOLk5PISbx5AUNZbQPucK9d9in1XOgaBwlk3WUg0p/H6 FPbA== 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=vOxLpW1T8Uj9t077Q8bS+yU7Ahwry4EiwNOjSEjIuJU=; b=Uu51PBNvbyqg1XfZbxG9ek4bbnhq3FSNtkwTguDja6m4QVhJQrycmFP/4YVqkMJM7E nwN+VgfT4shTW/DsaebUdyU/Q4aBcCH4es0mbUhi6YhqeiIbhBDJy0ZJdhnrMS/Q4HjE XZYg4oaEj0rUOoDpSnNdXk5yMXArzgAMhSlZtsBqA9mKZOXT/yOb/HbHI5oYnDw7HJlf R1/zIw+y6sJK06pzl68nW6C9KnW/GCDvkhRLTDCqCu0MtvBzLkUT2wDziPKluFKMBL7F oAEZZWIV4rGfj5jjM/g7FsLt3oLB/pJtiycXf35jQtDy9HBQAN1AmjZTE5vn3bIX+Dd5 97UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E98YI80r; 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 s24si4013615jan.84.2021.09.16.17.58.32; Thu, 16 Sep 2021 17:58:44 -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=E98YI80r; 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 S1345209AbhIPRGJ (ORCPT + 99 others); Thu, 16 Sep 2021 13:06:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:55312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347685AbhIPRAO (ORCPT ); Thu, 16 Sep 2021 13:00:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D3D2C6187A; Thu, 16 Sep 2021 16:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631809953; bh=CwGKRGNc/U1V19QPn06J7yQ2a8YzQXoQz4TbJHXJcP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E98YI80ryoID/NqOXM7ayDgzPiWNVlA4XbSuxcVZYkiyoraJx929PwT/LupPJnP1J BW7/CeE9zGtTZaX52Lgy22OuY3vSsuX9gH+Q05gTysA0CbXXu8Laq68XGCBrPJh3ak G06NvE3GVnjGuwTOn1zmlHE/hInTN24NXomkyKqo= 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 343/380] net: w5100: check return value after calling platform_get_resource() Date: Thu, 16 Sep 2021 18:01:40 +0200 Message-Id: <20210916155815.707731552@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155803.966362085@linuxfoundation.org> References: <20210916155803.966362085@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 a39ff4a47f3e1da3b036817ef436b1a9be10783a ] 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/wiznet/w5100.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c index ec5db481c9cd..15e13d6dc5db 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -1052,6 +1052,8 @@ static int w5100_mmio_probe(struct platform_device *pdev) mac_addr = data->mac_addr; mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mem) + return -EINVAL; if (resource_size(mem) < W5100_BUS_DIRECT_SIZE) ops = &w5100_mmio_indirect_ops; else -- 2.30.2