Skip to content

Commit

Permalink
EDAC: Fix calculation of returned address and next offset in edac_ali…
Browse files Browse the repository at this point in the history
…gn_ptr()

commit f8efca9 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: 8447c4d ("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>
  • Loading branch information
Eliav Farber authored and gregkh committed Feb 23, 2022
1 parent dc426f8 commit 624c164
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/edac/edac_mc.c
Expand Up @@ -213,7 +213,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;
Expand Down

0 comments on commit 624c164

Please sign in to comment.