Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638195pxv; Thu, 15 Jul 2021 12:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyKL3Y31jpq/KPjsFXoQshcrkRA+3bEqDuLivMsRlEhomaK14MCEDiytqHBkMJlmg3zMpW X-Received: by 2002:a17:906:859a:: with SMTP id v26mr7202816ejx.336.1626376165750; Thu, 15 Jul 2021 12:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376165; cv=none; d=google.com; s=arc-20160816; b=OESvLlS8YyQJp4+3gMXzF5YpAM1QnXH6zc/tZNe3hDdEmGADz7uEU3ZWTwfKhA8iSF ZuD3ghy2swgwXptrQjK0St0OBzBB50pQZmfr8V17DeYx+PWkwnqEdNPGpcd65rbHNKB3 rHaIhhCmNmaoiFXzJTfJAjJSoBn/vaaYjlATS5OEGUhxdwHWMAE1QFbdY0EcrPAqJ+fT y+rtoq7kOb6xBOXa/kIcE6+n2fkggaZZ6dSfd/7Cnn5onWZ0bK0NEIKtNSqsVFxbyv/b Z1pcMnuhABu7HPJK9+ID18FRnQuTUyWmfN0DwjUCTsVkE7+PJRqkrcsBOzrO78//P4dG bsQw== 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=h6JZdQrFqkISDo78un1njuOwPxN6UEEcYOJot5PvmTc=; b=xaKtsQ5+YDDLJnxvoCwvmtJ2JFqM322U/sbcSLI9ggAitEZXL2vWheTSk+sv3fH2GT W+niM2WFH5ww8sVantsHsum1wTNFgrctN5MOWmFP5lVHtCiGhWx4e6YqRcyVakzW9eaY +yjv+MXGSh/cnqN5pIWBqSh+I/CwTG8Hk1F2qQQfVODb970MWUvEkXbtOtoYbxPvDa1w VeX2XGOgNO9KsQz0Xn2SwPprCeM7NRh0AFywQwxE1N0VUSNJQT+L8tWlxuhnTym0tTrQ 0n1H6nEQFeEma0LB4Xi0ibcL/ZasQqDntm6ep1j6rkx7wf3nQewXeoj6IcoYUTcu6/5c kdAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xz7j2Zbq; 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 e22si1568856eds.201.2021.07.15.12.09.02; Thu, 15 Jul 2021 12:09:25 -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=xz7j2Zbq; 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 S243625AbhGOTJ6 (ORCPT + 99 others); Thu, 15 Jul 2021 15:09:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35148 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242326AbhGOS7h (ORCPT ); Thu, 15 Jul 2021 14:59:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 167FE613F5; Thu, 15 Jul 2021 18:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375391; bh=lBjcw4sOunxgl3Hqp9I4bME8z73756FTDxGKXLgCxdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xz7j2Zbq9fyJAsk4Fv3fWaAA5OWffaSTNSLNxREjqtCyVLQXJpOFk4FYzdEX41iDO wJ/2KvpbQ5hMUYQRSyPzCmN/mrc5Qdest4xLJHXOISqDoryhI40u+Ooq30zf2y0LBz rGPIwAhCLS/ijfFoz72thQksvvI6xT4TKSxVSyqg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 065/242] net: mscc: ocelot: check return value after calling platform_get_resource() Date: Thu, 15 Jul 2021 20:37:07 +0200 Message-Id: <20210715182603.977559478@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 f1fe19c2cb3fdc92a614cf330ced1613f8f1a681 ] It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value. Signed-off-by: Yang Yingliang Reviewed-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/ocelot/seville_vsc9953.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 84f93a874d50..deae923c8b7a 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -1206,6 +1206,11 @@ static int seville_probe(struct platform_device *pdev) felix->info = &seville_info_vsc9953; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + err = -EINVAL; + dev_err(&pdev->dev, "Invalid resource\n"); + goto err_alloc_felix; + } felix->switch_base = res->start; ds = kzalloc(sizeof(struct dsa_switch), GFP_KERNEL); -- 2.30.2