From nobody Fri Dec 19 20:12:11 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 B7A3DC38A2D for ; Mon, 24 Oct 2022 13:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235607AbiJXNLf (ORCPT ); Mon, 24 Oct 2022 09:11:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235572AbiJXNJD (ORCPT ); Mon, 24 Oct 2022 09:09:03 -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 DCB299F367; Mon, 24 Oct 2022 05:22:11 -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 83509B815B3; Mon, 24 Oct 2022 12:11:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D884EC433C1; Mon, 24 Oct 2022 12:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613461; bh=5gRo8IX02SsCQBABh41eIAqNTl+yzSyxn8vl9XNFPkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nIEXaxKv4lGWbcNS1eOuc9iqurLvwsK+nhlhDXTCIWEnT+Henla8f/UgPxlXOc7Vr OVOatDsoYUQpSPJf5uLgB6RTJ+RqrSD6hFkt5bDw8ERXjv+Y/KpJlgMVbDNTX8V2lz 95S1d3xspAgxDyKcLgi//VW09GVpieFinn9m9G9g= 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.4 145/255] mtd: rawnand: meson: fix bit map use in meson_nfc_ecc_correct() Date: Mon, 24 Oct 2022 13:30:55 +0200 Message-Id: <20221024113007.441345681@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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 28dc26e1a20a..a65aadb54af6 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