Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp466503pxb; Thu, 9 Sep 2021 05:13:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrdp7qaEjWI4MjJq0iG6Drt4h7nXLuxpt0jW4Z8VRLBS04gy73bmOcOK7dlWf+iqgmAVhb X-Received: by 2002:a05:6402:4d:: with SMTP id f13mr2820608edu.275.1631189628002; Thu, 09 Sep 2021 05:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631189627; cv=none; d=google.com; s=arc-20160816; b=laxXrmvqC2xjmKHFJspoDRDLpTPdkI9JVYh2s2Tj+XGDtzvB6CN9hdP05g+CGH/Yr0 W1GgQ6r3CGQHTLB8u5aFcqbag+IjvUndCLwSYeqk3NkSgl/5rgEH1Z5QbHmUK+cH+qYQ M0ozp/ngZfknxjwiDrNQs2KY0qPsoJ+nBosRRVPSzg8zB0LE/hvE2QOjAx22mEY8VMvD Z+X6G4Sg7tcTydxDb3t+GFyprGUJ9Wanimu/MIZN1TJnzFeM4vo7jjMkvqSQ6QW7nRUQ btm7iUeqKxYgkT4LNhSbth7tYBzK20F/Rm69LLEkSybsmsBOUuISzZG6eegTdVBLZ209 ylEQ== 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=MvIUr3ACYj4laLUf+oKfn33qwNt5VQnJ4S2HhRzs/sI=; b=F6Fd1nqegLWkDPuf4E52I8QvlqYhq7pv1zv+hOjjcj4Y5MZnhJU5W7FQej+PgPsYjw eKmwEA+xApzwpz+zGvCWyO7seoOIFQTojR1kJmiArPL7C1TuiQQSb0d0eyM/Ll2aaGun bTQpFMS4Nw3KM6WsX4Q/eUiR86o4BgeyLjKWQ1x6tL38Ta37STDW3u62va/+TIyOo2ID W63/eLmxopZwRvGGe2c1c8Lr+2S0yM6xrmuL9a5Pb17SUnUsgnpUdFV5gZ5nIRH8fc7P 4lcA3Yajs5PfVBobYJC2Zj95VJ9x0ff8sKpihNNazTmh+6xNu9WrtpnTdMoT1K6FCPzs ovpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RsIODibE; 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 l4si1641140edc.611.2021.09.09.05.13.21; Thu, 09 Sep 2021 05:13:47 -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=RsIODibE; 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 S1344160AbhIIMKp (ORCPT + 99 others); Thu, 9 Sep 2021 08:10:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:42022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236506AbhIIMCU (ORCPT ); Thu, 9 Sep 2021 08:02:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B022615E0; Thu, 9 Sep 2021 11:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187992; bh=NCxLR79vOFEL/5e0BQOkAXYhuTh3N8prrKjcQ0ciQMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsIODibEsnh8TYsKQKXxZP+oDMLr3AaQ1BC6q4aGYss9qKfPcbH38nnlhXzJeqkal jj0qRcv+9BxDQuO+7NbIShj3A4ogTnZKqdH36W8ceAhpVDvUU9PA+LzQQO42jUQImU 1M2FTzflNjc8OiZvNrnHr9lSipo0LEBpxEmnw/BwMjvCr+zwREzn5H42f8gC9yMAG9 g2LUjSlfxkLSUREQB4mJy4EFPoce3K4z7znABeAi6svlh//b5FTAULZoLFfat5mzvh V2+6ONYIyD7Za9MyHK8ctE147WI9Iu+BXfDq6z17B0Rpnxfi6ENKHQ72CRvWybDa0z QG1EUcOs4e7fg== 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.14 251/252] net: w5100: check return value after calling platform_get_resource() Date: Thu, 9 Sep 2021 07:41:05 -0400 Message-Id: <20210909114106.141462-251-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-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 811815f8cd3b..f974e70a82e8 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -1047,6 +1047,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