Skip to content

Commit f8efca9

Browse files
Eliav Farbersuryasaimadhu
authored andcommitted
EDAC: Fix calculation of returned address and next offset in edac_align_ptr()
Do alignment logic properly and use the "ptr" local variable 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. The patch in Fixes: which broke this actually wanted to "what we actually care about is the alignment of the actual pointer that's about to be returned." But it didn't check that alignment. Use the correct variable "ptr" for that. [ bp: Massage commit message. ] Fixes: 8447c4d ("edac: Do alignment logic properly in edac_align_ptr()") Signed-off-by: Eliav Farber <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 754e0b0 commit f8efca9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/edac/edac_mc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void *edac_align_ptr(void **p, unsigned int size, int n_elems)
215215
else
216216
return (char *)ptr;
217217

218-
r = (unsigned long)p % align;
218+
r = (unsigned long)ptr % align;
219219

220220
if (r == 0)
221221
return (char *)ptr;

0 commit comments

Comments
 (0)