Skip to contentSkip to conversation

mmc: at91_mci: fix pointer errors

PATCH New [email protected] 1 participant 1 message Mar 5, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 108/160 mmc: at91_mci: fix pointer errors

From: Wolfgang Muees <[email protected]>

Fixes two pointer errors, one which leads to memory overwrites if used with large chunks of data.

---

 drivers/mmc/host/at91_mci.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/host/at91_mci.c renamed from drivers/mmc/host/at91_mci.c~mmc-at91_mci-fix-pointer-errors +5 -3
diff -puN drivers/mmc/host/at91_mci.c~mmc-at91_mci-fix-pointer-errors drivers/mmc/host/at91_mci.c
@@ -227,11 +227,13 @@ static inline void at91_mci_sg_to_dma(st
 			for (index = 0; index < (amount / 4); index++)
 				*dmabuf++ = swab32(sgbuffer[index]);
 		} else {
-			memcpy(dmabuf, sgbuffer, amount);
-			dmabuf += amount;
+			char *tmpv = (char *)dmabuf;
+			memcpy(tmpv, sgbuffer, amount);
+			tmpv += amount;
+			dmabuf = (unsigned *)tmpv;
 		}
 
-		kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ);
+		kunmap_atomic(((void *)sgbuffer) - sg->offset, KM_BIO_SRC_IRQ);
 
 		if (size == 0)
 			break;

_