summaryrefslogtreecommitdiff
path: root/drivers/edac
diff options
context:
space:
mode:
authorEliav Farber <farbere@amazon.com>2022-01-13 13:06:19 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-23 14:03:20 +0300
commite1e26697d032628d2b769160566d1b03d9dfe155 (patch)
treef7b35c0ce9c93b3058a07bb9356960a4387b490a /drivers/edac
parente6da726eb67dc6478f84c129c9973612be3729e5 (diff)
downloadlinux-e1e26697d032628d2b769160566d1b03d9dfe155.tar.xz
EDAC: Fix calculation of returned address and next offset in edac_align_ptr()
commit f8efca92ae509c25e0a4bd5d0a86decea4f0c41e upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/edac_mc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 2c5975674723..a859ddd9d4a1 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -215,7 +215,7 @@ void *edac_align_ptr(void **p, unsigned int size, int n_elems)
else
return (char *)ptr;
- r = (unsigned long)p % align;
+ r = (unsigned long)ptr % align;
if (r == 0)
return (char *)ptr;