Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1678830pxb; Wed, 9 Feb 2022 02:00:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUHNdPyaQf/UEHu0zaXf+49tlA/NAtyZuECUk4Yx/ZNTPzyFbF7jHTSh579+PIu2ji/7Zy X-Received: by 2002:a17:90b:350c:: with SMTP id ls12mr1660391pjb.182.1644400815354; Wed, 09 Feb 2022 02:00:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400815; cv=none; d=google.com; s=arc-20160816; b=KC67trXIyEmK2/yocE6SMQFstVWYJ5GJYjm2WS0SyTb4XtdTHVGuW0CrfTmDoaTtW+ oQTTbSJYfjVZACrx5aqgsL9BEwwjKGACsBZ/SHvQJ2FTamCPU4wUeCRa8+jp4P2zYu77 B7cZRk8WGzAhrbw+M8ssJ6DzzGYSDVg9nxy00f4stZdtAY9Mi4MR3XcxmK/SWyKujUSM WGnU4YV/cwrraMlL9j9BUzGQUAOg9oMUUL2TV/p0ui9jJGDJOsdtg2KenRBpsW/imn2f gjmnr36uhFuHzaxyWzGQqELh/eakArHUEzplYkZTe8/4SI2010AYGbB7BIqTVbLW+7ro 7kUw== 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=UCtx4E7Nbn7qRmARuq/uEtBTbQhgwjKxeOw6WI+yHEE=; b=CK4Ok4/KrS7DL3vi8qPWh2VoeLJe8LifbQx8RNG5FrT594BHD+bpUpKQBbsOaLMvs8 Vydw2pWtlIYpcNTNfobgKz5oc19ZIfEFuFHFyqOj4xF0V+pW+uf/KDavT2FcA1IKb3nY ePsWy+ur5qpfm3qFXBbCqepRBHvb7OR2i8BB92CRroCMqwwTBPkortL0zrygbis7ZI73 YU1oKkLXqxisMoOUkn8eFw2JWipZhr57KBhwr4xvOYlmKaNPjnIEttuPaHYZ2pHjtxr9 UeHlRAQn4/X9UU29vk/6dZGXFAVlGD/ZA+wT+BkrzVlJBgwVe9TtNHQm9JKfuAFFXgsS xQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T3Og4X4Z; 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 kk2si4924046pjb.66.2022.02.09.02.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:00:15 -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=T3Og4X4Z; 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 22B47E07BF51; Wed, 9 Feb 2022 01:12:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383256AbiBGLV4 (ORCPT + 99 others); Mon, 7 Feb 2022 06:21:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381054AbiBGLQ6 (ORCPT ); Mon, 7 Feb 2022 06:16:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31C2C0401E1; Mon, 7 Feb 2022 03:16:54 -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 dfw.source.kernel.org (Postfix) with ESMTPS id D5BD561380; Mon, 7 Feb 2022 11:16:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6B29C004E1; Mon, 7 Feb 2022 11:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644232613; bh=lTG3C07Wf8/sEI8hwYExwGyUXAy1bir6utVxXmpv+8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3Og4X4Za3O51jXNAlXv9dHR6h+zPVoGmUtHsJYKZTxxKG9/A4MpJgoqqLI2drWPB CjAPwvtEYlH9iEDqglBFKtpahcyoc/5WLmms6QQYe8saRjyjN1ZAZrHTyX62QJRkib oPV/6BV2jUP3N/l1CehrT1Ro187W2Xe1/5AKdsWY= 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 4.19 67/86] spi: bcm-qspi: check for valid cs before applying chip select Date: Mon, 7 Feb 2022 12:06:30 +0100 Message-Id: <20220207103759.756812412@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103757.550973048@linuxfoundation.org> References: <20220207103757.550973048@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 @@ -520,7 +520,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)