Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1542419pxb; Thu, 16 Sep 2021 09:34:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzueLxXvZMmTdOxhVzPubxoS/CftU5c5EgFRxv+52p+OMHdSokxjtKVswGvtCGUyJpVa5Dv X-Received: by 2002:a05:6638:14cf:: with SMTP id l15mr5109096jak.8.1631810061646; Thu, 16 Sep 2021 09:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631810061; cv=none; d=google.com; s=arc-20160816; b=X+GLqm8V4N4PZoCPLz7tzgqfwYBBIK33WR2zwYvfogAtvcCG5hEclzvFsYqRm3QeDY VEXP5rrgupPTUBLlcTA6Exkoc5RpiWAaNI/hgHc/YeLmNfJqcC2SY/iWs87B2AQiGgvy jjy+mzx2n8uZCFF4+L/m7Mw6b2x6ZEPmJQNjhTi139fq9Uca0TP2jmFBN/vyLFRzWU8e z/caTdtOmApFj0Hx/ZWk2Qh/UMkNwByVOnRr8pGYMKVTeII4nBWCeaTc9tFWZMpjNxVr Ss3wmlzehRLL8KtqCZitV1dZS5m2pqtqD2f0hdQCr9xQa+H/4PhXorjwttxQwfKr9f9V whjg== 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=sHSSWZxiTX3TAKWm9qEnkfUbHNMef1Kc3P7BlNopRNw=; b=m7pnJc/riXupSg9LWEYtNk2ZpOsd/ML3sVvDSnXOO+rJ3q+ltc1FfK49x0J9eLYEyQ wdvLRBSBRj/4H+W28F9qUFcCLefqmXP5vbXKBM5Y7EckgkT85f8jx8x7FxRbOW708kaC zf72VdUT6ilaQx3QY4kbwhV1CueQRl1auq/44TfxAdIpRxb7HlpMnll2oP2yZgUbkKR1 vdX+A8TyXO63IzjeAOmVZmG7AVqMcTIAyA5so+Dmrd0Z8JM/L7cjmSrk4e2LKJTzaNy4 Xr9lxLabdC8q3ijwcyG4H295qWF6nsXL0aa8SfMOH1KNRx9Afd7n9DkbQ6xJfuxG5Rot /bhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z+cVeSNF; 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 b16si2617951ila.182.2021.09.16.09.34.08; Thu, 16 Sep 2021 09:34:21 -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=Z+cVeSNF; 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 S229696AbhIPQb3 (ORCPT + 99 others); Thu, 16 Sep 2021 12:31:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241777AbhIPQXW (ORCPT ); Thu, 16 Sep 2021 12:23:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E57456147F; Thu, 16 Sep 2021 16:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808937; bh=pfIM1sb5WYITdf6EuMAizbFU1tqBjQht/YjME59ikzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z+cVeSNFtSvUTik+dqkyDn5AqW/GQ916XNl1RvAOeuRy14pa333IAcLEDGrHELn4h a/GQWX5LECZU95GgkwbjlHE8iHYeKeAdYToz8/0LjLuP1/K2BYiLjZOSgr9z+hKF4m o0I/HpZIxYffGLdb6ggBWugI2LwK4OZFEAWYKYLw= 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 276/306] net: w5100: check return value after calling platform_get_resource() Date: Thu, 16 Sep 2021 18:00:21 +0200 Message-Id: <20210916155803.484331488@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 c0d181a7f83a..0b7135a3c585 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