Skip to contentSkip to conversation

spmi: Fix sandbox spmi driver memory corruption

PATCH In review Mateusz Kulikowski 3 participants 3 messages Apr 4, 2016 – Apr 12, 2016 SPMI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spmi: Fix sandbox spmi driver memory corruption

There is off-by-one error in sandbox_emul_gpio that causes segfault of certain tests.

EMUL_GPIO_REG_END is the address of last valid (emulated) register. This patch fixed this (by adding one more element to emulated register array).

---

 drivers/spmi/spmi-sandbox.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spmi/spmi-sandbox.c +2 -1
index 2f0fea0..980aff2 100644
@@ -35,7 +35,8 @@ struct sandbox_emul_fake_regs {
 };
 
 struct sandbox_emul_gpio {
-	struct sandbox_emul_fake_regs r[EMUL_GPIO_REG_END]; /* Fake registers */
+	/* Fake registers - need one more entry as REG_END is valid address. */
+	struct sandbox_emul_fake_regs r[EMUL_GPIO_REG_END + 1];
 };
 
 struct sandbox_spmi_priv {
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/1 spmi: Fix sandbox spmi driver memory corruption

Quoted 5 lines · Mateusz Kulikowski

There is off-by-one error in sandbox_emul_gpio that causes segfault of certain tests.

EMUL_GPIO_REG_END is the address of last valid (emulated) register. This patch fixed this (by adding one more element to emulated register array).

#2 lore raw
In reply to Mateusz Kulikowski
Quoted 8 lines · Mateusz Kulikowski

There is off-by-one error in sandbox_emul_gpio that causes segfault of certain tests.

EMUL_GPIO_REG_END is the address of last valid (emulated) register. This patch fixed this (by adding one more element to emulated register array).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160411/550561e8/attachment.sig>