From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F16F02F363F; Wed, 20 May 2026 18:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300873; cv=none; b=llbaUyiUG/BJhVh51KssSQTEtXdpim0LXHtS6PmSspNVUbzBT5ox4TmXnnIOgzKKbCI1lW7xLAeJFrlRtfP5/KuliXGWNl0wRr89nqf5krW8ZeqkLFs9PTWUK+6UzNwyglfeGSJdC7n+eliJV6Kw7ViYX4u3V4bSkITizPj4Y3A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779300873; c=relaxed/simple; bh=BMmVks72ZqHtFtSM9Hk4qqmufPkJfGzravrnJVRVutY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KVPuMpRfaODGXYOet1LvUkX99HkZ7JRBVjV9HGoF0SknyhmqCf+chuoYnX4wNo/K0lRJK26uaK/E1q1xV2+dFt4daAmFb/RkasURYk4ymprKnflA9NOvf2iGRvlUagOZmVRHJK4yhYupqhvq6HXye4HOg/pgFZoMg0bzN8ai8yQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MhOzxC4l; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MhOzxC4l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 632EC1F000E9; Wed, 20 May 2026 18:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779300871; bh=Lt/K5GbhxBsa197eMkDSHympqOR2B5Dp2DYDtplJP0s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MhOzxC4lCkTttViQixKUkAmYf1TXCCEwBJ2DfVZRszPskLMZ8APJxjULSfEIVJPcK C3eFbOa4uI68sKu3eMUbqzsn8APwKlTg0i5kzCnf56lkRm+VM62n2lwiQM5oeqx5by rfrbTEoMaCqjnLR9VNKhUke1AFOn3ltKOHyahJHE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shiji Yang , Michael Walle , Miquel Raynal , "Pratyush Yadav (Google)" , Sasha Levin Subject: [PATCH 6.12 338/666] mtd: spi-nor: swp: check SR_TB flag when getting tb_mask Date: Wed, 20 May 2026 18:19:09 +0200 Message-ID: <20260520162118.558253649@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260520162111.222830634@linuxfoundation.org> References: <20260520162111.222830634@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shiji Yang [ Upstream commit 94645aa41bf9ecb87c2ce78b1c3405bfb6074a37 ] When the chip does not support top/bottom block protect, the tb_mask must be set to 0, otherwise SR1 bit5 will be unexpectedly modified. Signed-off-by: Shiji Yang Fixes: 3dd8012a8eeb ("mtd: spi-nor: add TB (Top/Bottom) protect support") Reviewed-by: Michael Walle Reviewed-by: Miquel Raynal Signed-off-by: Pratyush Yadav (Google) Signed-off-by: Sasha Levin --- drivers/mtd/spi-nor/swp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/swp.c b/drivers/mtd/spi-nor/swp.c index fdc411f2a23c5..7208be75d850f 100644 --- a/drivers/mtd/spi-nor/swp.c +++ b/drivers/mtd/spi-nor/swp.c @@ -27,8 +27,10 @@ static u8 spi_nor_get_sr_tb_mask(struct spi_nor *nor) { if (nor->flags & SNOR_F_HAS_SR_TB_BIT6) return SR_TB_BIT6; - else + else if (nor->flags & SNOR_F_HAS_SR_TB) return SR_TB_BIT5; + else + return 0; } static u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor) -- 2.53.0