Commit 8447c4d1 authored by Chris Metcalf's avatar Chris Metcalf Committed by Mauro Carvalho Chehab

edac: Do alignment logic properly in edac_align_ptr()

The logic was checking the sizeof the structure being allocated to
determine whether an alignment fixup was required.  This isn't right;
what we actually care about is the alignment of the actual pointer that's
about to be returned.  This became an issue recently because struct
edac_mc_layer has a size that is not zero modulo eight, so we were
taking the correctly-aligned pointer and forcing it to be misaligned.
On Tile this caused an alignment exception.
Signed-off-by: default avatarChris Metcalf <cmetcalf@tilera.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b9bc5ddb
...@@ -164,7 +164,7 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems) ...@@ -164,7 +164,7 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
else else
return (char *)ptr; return (char *)ptr;
r = size % align; r = (unsigned long)p % align;
if (r == 0) if (r == 0)
return (char *)ptr; return (char *)ptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment