Skip to content

Commit

Permalink
drivers: edac: Fix bad bit shift operations
Browse files Browse the repository at this point in the history
Fix possible bad bit shift operations in fsl_mc_check()

Signed-off-by: Priyanka Singh <priyanka.singh@nxp.com>
Reviewed-by: Sherry Sun <sherry.sun@nxp.com>
  • Loading branch information
Priyanka Singh authored and intel-lab-lkp committed Apr 11, 2022
1 parent 1e0e7f1 commit c686e26
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions drivers/edac/fsl_ddr_edac.c
Expand Up @@ -6,7 +6,7 @@
* split out from mpc85xx_edac EDAC driver.
*
* Parts Copyrighted (c) 2013 by Freescale Semiconductor, Inc.
*
* Parts Copyrighted (c) 2022 NXP
* Author: Dave Jiang <djiang@mvista.com>
*
* 2006-2007 (c) MontaVista Software, Inc. This file is licensed under
Expand Down Expand Up @@ -334,18 +334,24 @@ static void fsl_mc_check(struct mem_ctl_info *mci)
sbe_ecc_decode(cap_high, cap_low, syndrome,
&bad_data_bit, &bad_ecc_bit);

if (bad_data_bit != -1)
if (bad_data_bit >= 0)
fsl_mc_printk(mci, KERN_ERR,
"Faulty Data bit: %d\n", bad_data_bit);
if (bad_ecc_bit != -1)
if (bad_ecc_bit >= 0)
fsl_mc_printk(mci, KERN_ERR,
"Faulty ECC bit: %d\n", bad_ecc_bit);

fsl_mc_printk(mci, KERN_ERR,
"Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n",
cap_high ^ (1 << (bad_data_bit - 32)),
cap_low ^ (1 << bad_data_bit),
syndrome ^ (1 << bad_ecc_bit));
"Faulty ECC bit: %d\n", bad_ecc_bit);
if ((bad_data_bit > 0 && bad_data_bit < 32) && bad_ecc_bit > 0) {
fsl_mc_printk(mci, KERN_ERR,
"Expected Data / ECC:\t%#8.8x_%08x / %#2.2x\n",
cap_high, cap_low ^ (1 << bad_data_bit),
syndrome ^ (1 << bad_ecc_bit));
}
if (bad_data_bit >= 32 && bad_ecc_bit > 0) {
fsl_mc_printk(mci, KERN_ERR,
"Expected Data / ECC:\t%#8.8x / %#2.2x\n",
cap_high ^ (1 << (bad_data_bit - 32)),
cap_low, syndrome ^ (1 << bad_ecc_bit));
}
}

fsl_mc_printk(mci, KERN_ERR,
Expand Down

0 comments on commit c686e26

Please sign in to comment.