Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp522090pxb; Thu, 9 Sep 2021 06:22:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoWNMJzUEzRoXD1oGD8wg/YwzbEFNISK1lbWc8KOZVgfEVWGtwuAftOxZLfxyoS3CxKO+1 X-Received: by 2002:a92:cb12:: with SMTP id s18mr2207882ilo.32.1631193731106; Thu, 09 Sep 2021 06:22:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193731; cv=none; d=google.com; s=arc-20160816; b=lfkl5qt5wOwHS4duypA2rJ+t9lMzsjbBbOvG3ZMbcF+2yBioii6D7WkOE1MV4PtOW7 WCYhfaOQkIf+jwtXcR1U/BYKdhWPE12ApiHVqVKJbZ7OOF71q5tSW+KHhUo8UwXJBGXo gdLCdGjVj89pSzLNnnqx8b3OH3nlP4JyoDpSFCvw0CcDrDX4UzGtFv168zWeKB75E3Nq 2VU4lDEeoSjWwtCx2+jiJiNO2fCOPFqLNHfkqkayMS/9VoP7IGb0p4eYakvsH7luQYmZ TX0pU5fstwomyaULxjPkjmoDGjRBNbPeKRE1V/+YH0Fv+GvWVGat/Ri75ZJnsj4sInxj adMQ== 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=a31bp3dxekPrtHNPewagvoOonSrkjxq/PeQe5UupxT8=; b=uqLOVqETCf4TYUuVeEo3w+xuAnQBnyA+tzINcX4/alsFjPbQVLsM6KmpKEYzPI1DYi Ms20mvQ9431DN8YMn292jyvyMZirXVSMFhTkuhJswEVCfypGLW4Pe87Zr8kHdb7svjc6 bO7PCYHNOPWmmWJm7lrJ3T/o1qMUHQMu3GZ3SJBEhcxEmfarV0Ifj9+39jDHuk5y2T/S 8MwAf0hniTPcyxAUU+N7RpYnZcKTkdnemEk8fuDF7TCRAL6dyFt3er37AGZ/mFV+qNY6 WMCG5yvtTSPU256ZPQCqlCkJjSSD1MWqljMJmHpSURmvlkKlAL3RPjAWEvCx9EPzTpgo hJ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pkg+oXvN; 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 u15si1393698jak.129.2021.09.09.06.21.56; Thu, 09 Sep 2021 06:22:11 -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=Pkg+oXvN; 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 S1356187AbhIINWC (ORCPT + 99 others); Thu, 9 Sep 2021 09:22:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357890AbhIINFS (ORCPT ); Thu, 9 Sep 2021 09:05:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16B5E61465; Thu, 9 Sep 2021 12:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188814; bh=9v5KXetP0jHSalqwz0z7Olnkt5XTLcj/fwIRehqg2Og=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pkg+oXvNnq6FqF/STV7PDmixzfqgq0mbcFnWXNWZ86ODt6EQGt8FxWMHChq9VsQMw oYGspSwfta4CPNs74bIWTlTiVHXHEr3jmNTfcBeLrnMJoWstkEW+lsp4hmTYL5qLkM uufqVcnVwKF+8btTm+12c/RSgcYVk5XXh1dbysWgcxCgJpIaFGRSBYbX8kLYCaPmyI i4/C0cJZJGWAMP1WfKshgSgXd9FNUZ36mNaEQyOOZ0WxvuTVIqeGo0SMlHo9nrZqBY 0YXcgUx+GjXHloUdACmLjLGdD3+8mFg2VYmn9jiuCdxmSlu5Fnjvcbc+kMjEsIi0nJ +ghZPBwXAU8Cw== 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 4.14 59/59] net: w5100: check return value after calling platform_get_resource() Date: Thu, 9 Sep 2021 07:59:00 -0400 Message-Id: <20210909115900.149795-59-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-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 2bdfb39215e9..87610d8b3462 100644 --- a/drivers/net/ethernet/wiznet/w5100.c +++ b/drivers/net/ethernet/wiznet/w5100.c @@ -1059,6 +1059,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