]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
EDAC/fsl_ddr: Fix bad bit shift operations
authorPriyanka Singh <priyanka.singh@nxp.com>
Wed, 16 Oct 2024 20:31:11 +0000 (16:31 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:47:45 +0000 (19:47 +0100)
commit99ec5eb5bbf3c00ce216f5d87e548c665a3b3ae7
tree00843d748df8dba69fb960bf0399569dce7e64a6
parente0269ea7a628fdeddd65b92fe29c09655dbb80b9
EDAC/fsl_ddr: Fix bad bit shift operations

[ Upstream commit 9ec22ac4fe766c6abba845290d5139a3fbe0153b ]

Fix undefined behavior caused by left-shifting a negative value in the
expression:

    cap_high ^ (1 << (bad_data_bit - 32))

The variable bad_data_bit ranges from 0 to 63. When it is less than 32,
bad_data_bit - 32 becomes negative, and left-shifting by a negative
value in C is undefined behavior.

Fix this by combining cap_high and cap_low into a 64-bit variable.

  [ bp: Massage commit message, simplify error bits handling. ]

Fixes: ea2eb9a8b620 ("EDAC, fsl-ddr: Separate FSL DDR driver from MPC85xx")
Signed-off-by: Priyanka Singh <priyanka.singh@nxp.com>
Signed-off-by: Li Yang <leoyang.li@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20241016-imx95_edac-v3-3-86ae6fc2756a@nxp.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/edac/fsl_ddr_edac.c