Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2142652iof; Tue, 7 Jun 2022 21:10:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv9DGfZCzgWKIyg1ihMstoBwyjKUeqjMjQtVTbKWKWGWU1LeCpPxyGdury9PhPK2CMNP8k X-Received: by 2002:a63:90c1:0:b0:3fc:7de1:b2b9 with SMTP id a184-20020a6390c1000000b003fc7de1b2b9mr28169904pge.440.1654661423844; Tue, 07 Jun 2022 21:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661423; cv=none; d=google.com; s=arc-20160816; b=vb8XSpMNfugKtrA8foTzzK3XcUxhV0+KLO25LF+wIEqwLGoPZkxYStrsnLIQYYd0SR d0JexhtEESVmWXe1e8qq2EmFCcQODekn/P2grHcrgErm5fRhccvXi9LZ36Fungjmnrnf YbyRiedJGegseMX50T+rVLloYQFdUo/vMau00xrwGFDUfQfeeN2Ir4CdywpcPKqR8KSu gesFrKPTgTNXU6Xxs8+WSt8R9+FVkeDs2VTFesqjkYomcf5Ofam58BlE4aoM1taIm4Gn WZVK2oXbUVUllJTL/YlNbvq1li4TQuA03LF+tHcH8/0+JGMda8ZEpmn97X67apLHRlow ay7Q== 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=dQiuTrr+KTEJEDKce4CEW9nUE1f/o4tX3731qdwgjblIslDpQmZQo06Cv878CJ0hd2 mcwazrbcFBPIlf6ySJ21GjVFfY1ngO5b7c/y5XcFzR8f0eCfnfyA/jAb0hA7lc2G0gMS CrkDlHVZiRswpWP5kj66tGTWtNx//gTiFUXn9bBC0mfmzGTRhr2zleKAr/ZJkHdD3yZk v6Cz/u3lu9ZV0uTQw83SaZMzyAlFi8vnfS2rRJdQkiMWc/OKf3hnJWrxEAU1erT/jFIq TJiwUfzZjtfNFKR80n+RCTEP8SFyr9/JKWYHaJRFgTbcz7yQUsFbfNe3v/pmLLjpVMUN aMNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1gaU6SbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x191-20020a6386c8000000b003fd9bbea2cesi12358144pgd.334.2022.06.07.21.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:10:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1gaU6SbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71914228F5A; Tue, 7 Jun 2022 20:41:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348060AbiFGRmE (ORCPT + 99 others); Tue, 7 Jun 2022 13:42:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347545AbiFGRau (ORCPT ); Tue, 7 Jun 2022 13:30:50 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1A941D0DB; Tue, 7 Jun 2022 10:27:15 -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 47AECB822B8; Tue, 7 Jun 2022 17:27:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7D74C36B0C; Tue, 7 Jun 2022 17:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622833; bh=h52zxNpYYU8WCZXmj5zjTKIXV+j+MQqMSEZmLGWkZrc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1gaU6SbO/M+vb6KsgP4fl7dZ9PbsVC3Hb96ZIVfWxBS3FRWC5FyrwEaZhYLaOdXsu o2Ql1cd9MbEwvT2nkp8pEvVOBHmPbZBuEZIccx9V3tnassWXpl2pWiPIYl8PAb40/X 1zq66/JRiPjF1yqOiLLGVPp2/qFZgTUQRD/st5XA= 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.10 197/452] spi: spi-fsl-qspi: check return value after calling platform_get_resource_byname() Date: Tue, 7 Jun 2022 19:00:54 +0200 Message-Id: <20220607164914.435376679@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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