All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][V2] EDAC/i10nm: shift exponent is negative
@ 2023-07-03 16:25 Koba Ko
       [not found] ` <4ec2b7d2-11a5-6ab6-087a-175ed31faca4@web.de>
  2023-07-04 12:02 ` [PATCH][V2] " Dan Carpenter
  0 siblings, 2 replies; 21+ messages in thread
From: Koba Ko @ 2023-07-03 16:25 UTC (permalink / raw)
  To: Borislav Petkov, Tony Luck, James Morse, Mauro Carvalho Chehab,
	Robert Richter, linux-edac, linux-kernel

UBSAN complains this error
~~~
 UBSAN: shift-out-of-bounds in drivers/edac/skx_common.c:369:16
 shift exponent -66 is negative
 Call Trace:
  <TASK>
  dump_stack_lvl+0x48/0x70
  dump_stack+0x10/0x20
  __ubsan_handle_shift_out_of_bounds+0x1ac/0x360
  skx_get_dimm_info.cold+0x91/0x175 [i10nm_edac]
  ? kvasprintf_const+0x2a/0xb0
  i10nm_get_dimm_config+0x23c/0x340 [i10nm_edac]
  skx_register_mci+0x139/0x1e0 [i10nm_edac]
  ? __pfx_i10nm_get_dimm_config+0x10/0x10 [i10nm_edac]
  i10nm_init+0x403/0xd10 [i10nm_edac]
  ? __pfx_i10nm_init+0x10/0x10 [i10nm_edac]
  do_one_initcall+0x5b/0x250
  do_init_module+0x68/0x260
  load_module+0xb45/0xcd0
  ? kernel_read_file+0x2a4/0x320
  __do_sys_finit_module+0xc4/0x140
  ? __do_sys_finit_module+0xc4/0x140
  __x64_sys_finit_module+0x18/0x30
  do_syscall_64+0x58/0x90
  ? syscall_exit_to_user_mode+0x29/0x50
  ? do_syscall_64+0x67/0x90
  ? syscall_exit_to_user_mode+0x29/0x50
  ? do_syscall_64+0x67/0x90
  ? do_syscall_64+0x67/0x90
  ? __flush_smp_call_function_queue+0x122/0x1f0
  ? exit_to_user_mode_prepare+0x30/0xb0
  ? irqentry_exit_to_user_mode+0x9/0x20
  ? irqentry_exit+0x43/0x50
  ? sysvec_call_function+0x4b/0xd0
  entry_SYSCALL_64_after_hwframe+0x72/0xdc
~~~

when get rows, cols and ranks, the returned error value doesn't be
handled.

check the return value is EINVAL, if yes, directly return 0.

Signed-off-by: Koba Ko <koba.ko@canonical.com>
---
V2: make error-print explicitly
---
 drivers/edac/skx_common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c
index 2a00e0503f0d5..ac61db72d2e6b 100644
--- a/drivers/edac/skx_common.c
+++ b/drivers/edac/skx_common.c
@@ -330,7 +330,7 @@ static int skx_get_dimm_attr(u32 reg, int lobit, int hibit, int add,
 	u32 val = GET_BITFIELD(reg, lobit, hibit);
 
 	if (val < minval || val > maxval) {
-		edac_dbg(2, "bad %s = %d (raw=0x%x)\n", name, val, reg);
+		skx_printk(KERN_ERR, "bad %s = %d (raw=0x%x)\n", name, val, reg);
 		return -EINVAL;
 	}
 	return val + add;
@@ -351,6 +351,8 @@ int skx_get_dimm_info(u32 mtr, u32 mcmtr, u32 amap, struct dimm_info *dimm,
 	ranks = numrank(mtr);
 	rows = numrow(mtr);
 	cols = imc->hbm_mc ? 6 : numcol(mtr);
+	if (ranks == -EINVAL || rows == -EINVAL || cols == -EINVAL)
+		return 0;
 
 	if (imc->hbm_mc) {
 		banks = 32;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2023-07-10  8:08 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-03 16:25 [PATCH][V2] EDAC/i10nm: shift exponent is negative Koba Ko
     [not found] ` <4ec2b7d2-11a5-6ab6-087a-175ed31faca4@web.de>
2023-07-03 21:51   ` [PATCH v2] " Luck, Tony
2023-07-04  1:50     ` Koba Ko
2023-07-04  3:14       ` Luck, Tony
2023-07-05  4:08       ` Luck, Tony
2023-07-05  8:45         ` Koba Ko
2023-07-05 15:22           ` Luck, Tony
2023-07-06 14:11             ` Zhuo, Qiuxu
2023-07-06 17:40               ` Koba Ko
2023-07-07  3:34                 ` Zhuo, Qiuxu
2023-07-09 15:42                   ` Koba Ko
2023-07-10  1:18                     ` Zhuo, Qiuxu
2023-07-10  6:25                     ` Dan Carpenter
2023-07-10  8:08                       ` Zhuo, Qiuxu
2023-07-04  2:20     ` Koba Ko
2023-07-04  4:59       ` Koba Ko
     [not found]         ` <9c27530e-21f9-15ce-5116-5af5b0c25f53@web.de>
2023-07-04  8:05           ` Koba Ko
2023-07-04  8:17           ` Koba Ko
     [not found]             ` <706f49e8-d536-651a-2f19-394518633b53@web.de>
2023-07-04  8:59               ` [v2/v3] " Koba Ko
2023-07-04 12:02 ` [PATCH][V2] " Dan Carpenter
2023-07-04 12:32   ` Koba Ko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.