linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] EDAC/mc: Fix memory alignment calculation formula
@ 2020-05-16 16:21 wata2ki
  2020-06-03 11:28 ` Borislav Petkov
  2020-06-17 17:58 ` Borislav Petkov
  0 siblings, 2 replies; 5+ messages in thread
From: wata2ki @ 2020-05-16 16:21 UTC (permalink / raw)
  To: linux-edac; +Cc: Naoto Yamaguchi

From: Naoto Yamaguchi <i33399_YAMAGUCHI@aisin-aw.co.jp>

During the development of the off-tree driver, we found a bug that
causes alignment fault exception in mutex_lock.

Line of the code:
ffffffc010536ce4: c85ffe62 ldaxr x2, [x19]

Register value:
x19: ffffff800e90f6c4

This problem was caused by the alignment error of pvt_info
in struct mem_ctl_info.  It is caused by a calculation formula
error in edac_align_ptr.

Existing calculation formula is using variable p, but this
variable is address of the pointer variable not memory offset.
In this calculation formula should use *p.

Signed-off-by: Naoto Yamaguchi <i33399_YAMAGUCHI@aisin-aw.co.jp>
---
 drivers/edac/edac_mc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 mode change 100644 => 100755 drivers/edac/edac_mc.c

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
old mode 100644
new mode 100755
index 75ede27bdf6a..70929f136dd7
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -271,7 +271,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)(*p) % align;
 
 	if (r == 0)
 		return (char *)ptr;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-17 17:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 16:21 [PATCH] EDAC/mc: Fix memory alignment calculation formula wata2ki
2020-06-03 11:28 ` Borislav Petkov
2020-06-03 13:07   ` Naoto YAMAGUCHI
     [not found]   ` <CABBJnRYZTsnOjNdd9x5ZS_Vb56yvEJWsLxEERYPj-m3HfAqx1Q@mail.gmail.com>
2020-06-03 17:36     ` Borislav Petkov
2020-06-17 17:58 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).