Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2155066iof; Tue, 7 Jun 2022 21:35:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYwfj1LXdR7F+eVveSvFZswjjk+aXiFnU6zs42kPkGdkE9RG59CstXkb6kjCaJOnvQg7fZ X-Received: by 2002:a17:902:e88e:b0:163:ee82:ffb with SMTP id w14-20020a170902e88e00b00163ee820ffbmr32952955plg.142.1654662949228; Tue, 07 Jun 2022 21:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662949; cv=none; d=google.com; s=arc-20160816; b=lctKG98fdk6V55hrvsLmKTsHi8iY97oKJhYTMkry9Km8btCbNuRbN6IJu5/uFFab3l 6Rle99Lki6EP3thzqrQ8mEBjqFmFHymBUbDB/WEEOnC+VPk7QibukV13YXWjn61Zq7vy j0e8NNgZ+fhZ8C80PLz9D189uvJ2lqVUEu8uLxTG+THSoEdmUdJ9irqjJBUc0GoAvz6V SkmEF65rV8dwt/OLzGvIfgNXkd1m8sFrp2uaGqkAolVORLQ3oBAQwKdcDfyRs6tc8TxO PjjUoczgXhVp54uG9VSdE/p1QFaQgeFFeKmY3ieQ2Awcj88g2l+s6Nocvv06UaCuYfx8 fwEg== 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=RVJv9NLpFANYbOKMGLvITUVFwJ41gBR7sIPoS6ZiUhA=; b=kj+UdMjXPqAUGlMbwVkAOZunExhHeCPNkhx0FLeVwd+9rySoavZxml3ssW0vZTzdFu 4I55vJo0mid/aG9Gm5JcjSvdxU3M+upCwMZdlOPYkMAYsh7V6detUPp9jp8GyAE/ybFT 2mwADsLJPfV/lWCcpU7fT8JYPjfCJRSQNZqH38UNTj0V92CBdaw2pM21OXL2NrIFKL7Y rSdrcXTqrYpfbWkIxYN4PqHUox1rnjhl0KJipU9ksWYNuh8Ta2eNkJINmmEW8CWgwG8e cUlSHZfKT7XmXZe9+3Qubh4re9Asm89TaTuDzwjripRXNpWf56L6ZnxUKWUc1Wf128fD FyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lh5f4Uyq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u70-20020a638549000000b003fe2e64fcbesi1326159pgd.381.2022.06.07.21.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:35:49 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lh5f4Uyq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F0520271A8E; Tue, 7 Jun 2022 21:03:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385215AbiFGWpk (ORCPT + 99 others); Tue, 7 Jun 2022 18:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379510AbiFGVcq (ORCPT ); Tue, 7 Jun 2022 17:32:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D4E114AF57; Tue, 7 Jun 2022 12:04:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 09887B823B0; Tue, 7 Jun 2022 19:04:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FDFAC385A2; Tue, 7 Jun 2022 19:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628650; bh=h52zxNpYYU8WCZXmj5zjTKIXV+j+MQqMSEZmLGWkZrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lh5f4Uyqf4nbNK5iv7MifFpdpysdAHkf4XbMEyxkckEr87kLJPqxK60e981OViGrk zLhja9qrAkkvW8baV4FU1bY7lnElJkkonV6548mzq2Uh8HxISSTNBusW+z3GbWMB9M nJhP/viaCjk70LIxClO8+dSZZN53KSoka6sIuMw8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yingliang , Mark Brown , Sasha Levin Subject: [PATCH 5.18 405/879] spi: spi-fsl-qspi: check return value after calling platform_get_resource_byname() Date: Tue, 7 Jun 2022 18:58:43 +0200 Message-Id: <20220607165014.618258607@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit a2b331ac11e1cac56f5b7d367e9f3c5796deaaed ] It will cause null-ptr-deref if platform_get_resource_byname() returns NULL, we need check the return value. Fixes: 858e26a515c2 ("spi: spi-fsl-qspi: Reduce devm_ioremap size to 4 times AHB buffer size") Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20220505093954.1285615-1-yangyingliang@huawei.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-fsl-qspi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c index 9851551ebbe0..46ae46a944c5 100644 --- a/drivers/spi/spi-fsl-qspi.c +++ b/drivers/spi/spi-fsl-qspi.c @@ -876,6 +876,10 @@ static int fsl_qspi_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "QuadSPI-memory"); + if (!res) { + ret = -EINVAL; + goto err_put_ctrl; + } q->memmap_phy = res->start; /* Since there are 4 cs, map size required is 4 times ahb_buf_size */ q->ahb_addr = devm_ioremap(dev, q->memmap_phy, -- 2.35.1