From nobody Fri Dec 19 18:43:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EFDBC3A59D for ; Sat, 22 Oct 2022 08:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233157AbiJVILu (ORCPT ); Sat, 22 Oct 2022 04:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233397AbiJVIJo (ORCPT ); Sat, 22 Oct 2022 04:09:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08E9F2C6E8C; Sat, 22 Oct 2022 00:54:12 -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 635B9B82E05; Sat, 22 Oct 2022 07:54:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 035E5C433B5; Sat, 22 Oct 2022 07:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425243; bh=2aSqJ9LbDxNENvjzdwzi9Im+SVsBxTeYEvCqP3aIeus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K8zTKIh4UCFOQqs/YlUJBKaFOdiUyz53wmZL+fFMjhiH3JgydvLuPw5UMy8oxtgLH qGXt0ainVaQCIYYru0uNQuOc9REJzgQ9Rkrr/EXIYu/srptje6NaPMpYpbF57xcQKh Gxq41c+hHFP0EIaKqdKEzd2toCVX9stltN5ZPv/Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Liang Yang , Miquel Raynal , Sasha Levin Subject: [PATCH 5.19 438/717] mtd: rawnand: meson: fix bit map use in meson_nfc_ecc_correct() Date: Sat, 22 Oct 2022 09:25:17 +0200 Message-Id: <20221022072517.733903211@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Dan Carpenter [ Upstream commit 3e4ad3212cf22687410b1e8f4e68feec50646113 ] The meson_nfc_ecc_correct() function accidentally does a right shift instead of a left shift so it only works for BIT(0). Also use BIT_ULL() because "correct_bitmap" is a u64 and we want to avoid shift wrapping bugs. Fixes: 8fae856c5350 ("mtd: rawnand: meson: add support for Amlogic NAND fla= sh controller") Signed-off-by: Dan Carpenter Acked-by: Liang Yang Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/YuI2zF1hP65+LE7r@kili Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/meson_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson= _nand.c index 032180183339..b97adeee4cc1 100644 --- a/drivers/mtd/nand/raw/meson_nand.c +++ b/drivers/mtd/nand/raw/meson_nand.c @@ -454,7 +454,7 @@ static int meson_nfc_ecc_correct(struct nand_chip *nand= , u32 *bitflips, if (ECC_ERR_CNT(*info) !=3D ECC_UNCORRECTABLE) { mtd->ecc_stats.corrected +=3D ECC_ERR_CNT(*info); *bitflips =3D max_t(u32, *bitflips, ECC_ERR_CNT(*info)); - *correct_bitmap |=3D 1 >> i; + *correct_bitmap |=3D BIT_ULL(i); continue; } if ((nand->options & NAND_NEED_SCRAMBLING) && @@ -800,7 +800,7 @@ static int meson_nfc_read_page_hwecc(struct nand_chip *= nand, u8 *buf, u8 *data =3D buf + i * ecc->size; u8 *oob =3D nand->oob_poi + i * (ecc->bytes + 2); =20 - if (correct_bitmap & (1 << i)) + if (correct_bitmap & BIT_ULL(i)) continue; ret =3D nand_check_erased_ecc_chunk(data, ecc->size, oob, ecc->bytes + 2, --=20 2.35.1