Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC/bluefield: Don't use bluefield_edac_readl() result on error

The bluefield_edac_readl() routine returns an uninitialized result on error
paths. In those cases the calling routine should not use the uninitialized
result. The driver should simply log the error, and then return early.

Fixes: e41967575474 ("EDAC/bluefield: Use Arm SMC for EMI access on BlueField-2")
Signed-off-by: David Thompson <davthompson@nvidia.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shravan Kumar Ramani <shravankr@nvidia.com>
Link: https://lore.kernel.org/20250318214747.12271-1-davthompson@nvidia.com

authored by

David Thompson and committed by
Borislav Petkov (AMD)
ea3b0b7f 2b2408ac

+15 -5
+15 -5
drivers/edac/bluefield_edac.c
··· 199 199 * error without the detailed information. 200 200 */ 201 201 err = bluefield_edac_readl(priv, MLXBF_SYNDROM, &dram_syndrom); 202 - if (err) 202 + if (err) { 203 203 dev_err(priv->dev, "DRAM syndrom read failed.\n"); 204 + return; 205 + } 204 206 205 207 serr = FIELD_GET(MLXBF_SYNDROM__SERR, dram_syndrom); 206 208 derr = FIELD_GET(MLXBF_SYNDROM__DERR, dram_syndrom); ··· 215 213 } 216 214 217 215 err = bluefield_edac_readl(priv, MLXBF_ADD_INFO, &dram_additional_info); 218 - if (err) 216 + if (err) { 219 217 dev_err(priv->dev, "DRAM additional info read failed.\n"); 218 + return; 219 + } 220 220 221 221 err_prank = FIELD_GET(MLXBF_ADD_INFO__ERR_PRANK, dram_additional_info); 222 222 223 223 ecc_dimm = (err_prank >= 2 && priv->dimm_ranks[0] <= 2) ? 1 : 0; 224 224 225 225 err = bluefield_edac_readl(priv, MLXBF_ERR_ADDR_0, &edea0); 226 - if (err) 226 + if (err) { 227 227 dev_err(priv->dev, "Error addr 0 read failed.\n"); 228 + return; 229 + } 228 230 229 231 err = bluefield_edac_readl(priv, MLXBF_ERR_ADDR_1, &edea1); 230 - if (err) 232 + if (err) { 231 233 dev_err(priv->dev, "Error addr 1 read failed.\n"); 234 + return; 235 + } 232 236 233 237 ecc_dimm_addr = ((u64)edea1 << 32) | edea0; 234 238 ··· 258 250 return; 259 251 260 252 err = bluefield_edac_readl(priv, MLXBF_ECC_CNT, &ecc_count); 261 - if (err) 253 + if (err) { 262 254 dev_err(priv->dev, "ECC count read failed.\n"); 255 + return; 256 + } 263 257 264 258 single_error_count = FIELD_GET(MLXBF_ECC_CNT__SERR_CNT, ecc_count); 265 259 double_error_count = FIELD_GET(MLXBF_ECC_CNT__DERR_CNT, ecc_count);