Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp512114pxb; Thu, 9 Sep 2021 06:11:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIq0nGDqJPetOmfZsHE+ORgzXLgjMZB61u9fVf6Jj5K3KNrQsVwa9/bYwKNR0rbT0M5ybT X-Received: by 2002:a05:6402:455:: with SMTP id p21mr3097253edw.309.1631193068112; Thu, 09 Sep 2021 06:11:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193068; cv=none; d=google.com; s=arc-20160816; b=AHCRGtDlc1DHcox/byV3uR0nUaQdOx+O7qTAv89Y/85ujJjdHCc2eI48g60yeKctw3 0jBhb1+aW4iULE5zFz7ufgeeW5SV/Ht1IqCtX8auvdUGZPIdCPZoLyieUk8qcJV6cPFl 6JOhsOE0m5l11L5+nb1jw1S4XmHysKu7WGjz2SecF5l6EqoQK1NJq62Ghpr3WtvFMFhf dboAV4TObxyEbJ0n0JqcgA23RQQ2OrNWr1njIn8stKQfUrmOjr8BU7YDrZFZXa7UNKm3 jZjab3b7Vn//dmcAp9af3Op1zBpTc68BsvggZkObvVA8fSiP/CrboTB3IGwRsywBzzS6 OfrQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YVxegvsDULGHdaRcSZhLKM5f4JTL8ih6xmR33QyaGTo=; b=m6iWlAMiakaWN+4TDTxN7+C6uuV9BcA+3Vc1/7S3LpI7kwGrq7QE3pnvKr1bxwvBuN IiOXhAonlX2ac4PxavPQcIV2/E5O7K/hggQUXKKOWPtqDvaHdMXgqt866gDFxdmC5J9g BNzXbAAqfsgHhA5tSHLd9+D6z0Yp+312MXh/9RAQG6SFlxumMt88EvsMqYDdglodpxpQ QTrX+BsO8Z1Uqkc6+bYG9PwCGgqvkyV3A1YRIAw33GS0njWo7BxPzCXRoXLSQPbnUvZD Pl5lDsmQNpbmuTt1eaAJXCOXejF6xPSI8Ln+gDwBNtml8uuZqJz1WBbdfz88e5nP0qbP cprw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=asm8hCgZ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q16si1547080ejy.322.2021.09.09.06.10.40; Thu, 09 Sep 2021 06:11:08 -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=@kernel.org header.s=k20201202 header.b=asm8hCgZ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357844AbhIINFC (ORCPT + 99 others); Thu, 9 Sep 2021 09:05:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:42578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349533AbhIIMvn (ORCPT ); Thu, 9 Sep 2021 08:51:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B3B1E613BD; Thu, 9 Sep 2021 11:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188645; bh=QF6wCS71/GyPFqKLTaD984ITltx47FzIXEJWlJH2qzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=asm8hCgZ+JLuMT6+MCZTdjMKiMDASQq/Ki5J+vUU+PcYh+YyMOmcNqOHnFgxizvjI rPVjsGZvj5YTcvoI2SCv/EXjyzvX9rDo1J/wTFlI2hixXW5FOTFKGhCOvMJVtws8Jt RrsGzg/ky+VPZFF3vLS6IXRdtxKNXm3faJyhHmi4YyphFvLFSG+Ou9DjMYJvFxiDAi qSQaHV6zPkIrH7Ud4KkDOjCrHP9DLJmXbcKcTre6mPiA+91p/41wDN1PljeFt0pynH NHHyMB7t5ueoTNgZv5eHay7Vo8GNJLX7eu1pg2hyl1hboZVnrzmU1a5Ye/7mX09JFj 8Drnt1a146lIA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yang Yingliang , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 109/109] net: w5100: check return value after calling platform_get_resource() Date: Thu, 9 Sep 2021 07:55:06 -0400 Message-Id: <20210909115507.147917-109-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 bede1ff289c5..a65b7291e12a 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