From 0b3520f2df8e4e5dad6a7b2743d037bf06c22024 Mon Sep 17 00:00:00 2001 From: Wolfgang Muees Date: Fri, 5 Mar 2010 13:43:38 -0800 Subject: [PATCH] mmc: at91_mci: fix pointer errors Fixes two pointer errors, one which leads to memory overwrites if used with large chunks of data. Signed-off-by: Wolfgang Muees Signed-off-by: Nicolas Ferre Cc: Andrew Victor Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/mmc/host/at91_mci.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 63924e0c7ea9..4e1b2e6288da 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c @@ -227,11 +227,13 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data 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;