Skip to content

Commit

Permalink
edac: Do alignment logic properly in edac_align_ptr()
Browse files Browse the repository at this point in the history
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: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Chris Metcalf authored and Mauro Carvalho Chehab committed Jun 11, 2012
1 parent b9bc5dd commit 8447c4d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/edac/edac_mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void *edac_align_ptr(void **p, unsigned size, int n_elems)
else
return (char *)ptr;

r = size % align;
r = (unsigned long)p % align;

if (r == 0)
return (char *)ptr;
Expand Down

0 comments on commit 8447c4d

Please sign in to comment.