Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1823335pxb; Wed, 9 Feb 2022 05:22:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPbAaro3MtWYgwDJXUkPX9r7hPkCfhu4oJZpYZBEEXF8iymqlgP5dkZX3TS0JlEetjwZoN X-Received: by 2002:a17:903:2449:: with SMTP id l9mr2403564pls.116.1644412929789; Wed, 09 Feb 2022 05:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644412929; cv=none; d=google.com; s=arc-20160816; b=rWQ6yNlHwgLJnIiMRHNO3KRvDqOSSm/A39OOfgxzVfpNufVYnZWEEbFiA/dF9g18+S MpkwtkK41Jobj6odmxqmwAwj6Zu9nh/m67OHRm84WHcug4UF6oHMvjER6BsJw85m2CnJ 1JpUDMjJDPbBIi40GeVuKMfYy+b2SMDhCM5f7rFT5qNXTYe7/xvpZZZVQdIIaRh4vBue ZaJMKfURhAMNxDLunb/hOW7OektH1THOkDadPETDqFSOqQZblftJXrMYEklskD9YhY4z CdxWJ0ReocyC2KsXAogObSs4792sfvNdSEEYaUBVCxHtIzod10GHGVM8ZDTZEQjj/2mO 7wUg== 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=St4v4L+bm/t7TLMgO7Xz33wEBOVHkQe9KWhyK9z7s6w=; b=Jux8IXEHXRHhcYGOvke+qPGEwRIYimDjv7q57IZ5y0jDK2jV0mjvLARRE6Rq1yy1hk TRv3cAdRuWUyPoojvr1n5quk/tjjoq3G+3qzdxl6Bd96q0L8/yDxVA2mcy4FtGmGe3+4 kcbuA9QCwXtmTlEf06chYxep4hRUarOapqG2L+/ddzctT9fIJ2InlBl7FclmqJ44BVrY PZLAZIRsE2dNADV/cyAtONVqQqC+SNnmFFpgGmiLnj5T12FXlMSyt2ixugbDI/0klbxv ggUGZxzVkDTKIObBrz/kp0Ll1pJwgY3ldZNfRG1SgtHnVe990MIkNo5vA2Uzg9pU2zP4 XuAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0Pg76pc2; 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 j63si15247530pge.117.2022.02.09.05.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:22:09 -0800 (PST) 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=0Pg76pc2; 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 2D899E02F543; Wed, 9 Feb 2022 02:08:27 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384111AbiBGLYs (ORCPT + 99 others); Mon, 7 Feb 2022 06:24:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382420AbiBGLTF (ORCPT ); Mon, 7 Feb 2022 06:19:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D1CC043181; Mon, 7 Feb 2022 03:19:03 -0800 (PST) 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 782B3B81028; Mon, 7 Feb 2022 11:19:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94EE7C004E1; Mon, 7 Feb 2022 11:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232741; bh=XBaQoyU9Gn/uFmh11tRhdToBtsSitNApPt/xeAZ2kdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Pg76pc21m6nvCGiOU0TMg39mdzzMzJkDgynDbelvyPUOXxhY3xXGfBki/3kQd9VH Lky6Nhm7X14wEOaexVLrtvA1jIJOgtXA3l0Piih0DF0KppT5EnUbwzvpEggdw0pMwP Ek2VV4qi9EktMsOIIaI8UZQdwqeEqv1pA9BvG+H0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Dasu , Florian Fainelli , Mark Brown Subject: [PATCH 5.4 21/44] spi: bcm-qspi: check for valid cs before applying chip select Date: Mon, 7 Feb 2022 12:06:37 +0100 Message-Id: <20220207103753.843606198@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103753.155627314@linuxfoundation.org> References: <20220207103753.155627314@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=-2.0 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=no 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: Kamal Dasu commit 2cbd27267ffe020af1442b95ec57f59a157ba85c upstream. Apply only valid chip select value. This change fixes case where chip select is set to initial value of '-1' during probe and PM supend and subsequent resume can try to use the value with undefined behaviour. Also in case where gpio based chip select, the check in bcm_qspi_chip_select() shall prevent undefined behaviour on resume. Fixes: fa236a7ef240 ("spi: bcm-qspi: Add Broadcom MSPI driver") Signed-off-by: Kamal Dasu Acked-by: Florian Fainelli Link: https://lore.kernel.org/r/20220127185359.27322-1-kdasu.kdev@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-bcm-qspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/spi/spi-bcm-qspi.c +++ b/drivers/spi/spi-bcm-qspi.c @@ -509,7 +509,7 @@ static void bcm_qspi_chip_select(struct u32 rd = 0; u32 wr = 0; - if (qspi->base[CHIP_SELECT]) { + if (cs >= 0 && qspi->base[CHIP_SELECT]) { rd = bcm_qspi_read(qspi, CHIP_SELECT, 0); wr = (rd & ~0xff) | (1 << cs); if (rd == wr)