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: 8447c4d15e35 ("edac: Do alignment logic properly in edac_align_ptr()")
Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220113100622.12783-2-farbere@amazon.com

authored by Eliav Farber and committed by Borislav Petkov f8efca92 754e0b0e

Changed files
+1 -1
drivers
edac
+1 -1
drivers/edac/edac_mc.c
··· 215 215 else 216 216 return (char *)ptr; 217 217 218 - r = (unsigned long)p % align; 218 + r = (unsigned long)ptr % align; 219 219 220 220 if (r == 0) 221 221 return (char *)ptr;