[PATCH 1/4] EDAC: Fix calculation of returned address and next offset in edac_align_ptr()
From: Eliav Farber
Date: Thu Jan 13 2022 - 05:06:42 EST
Do alignment logic properly and use 'ptr' for calculating the remainder
of the alignment.
This became an issue because 'struct edac_mc_layer' has a size that is
not zero modulo eight, and the next offset that was prepared for the
private-data was unaligned, causing an alignment exception.
Signed-off-by: Eliav Farber <farbere@xxxxxxxxxx>
---
drivers/edac/edac_mc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index fd440b35d76e..61d72bd96754 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -265,7 +265,7 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
else
return (char *)ptr;
- r = (unsigned long)p % align;
+ r = (unsigned long)ptr % align;
if (r == 0)
return (char *)ptr;
--
2.32.0