From: Mike Frysinger Date: Wed, 7 Jan 2009 15:14:38 +0000 (+0800) Subject: Blackfin arch: check pointers in safe_dma_memcpy X-Git-Tag: v2.6.29-rc1~189^2~61 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=49946e7329fa38d79aed1a9ef4a64c320ada305d;p=linux-2.6-omap-h63xx.git Blackfin arch: check pointers in safe_dma_memcpy Check pointers in safe_dma_memcpy as this is the entry point for user-space code Signed-off-by: Mike Frysinger Signed-off-by: Bryan Wu --- diff --git a/arch/blackfin/kernel/bfin_dma_5xx.c b/arch/blackfin/kernel/bfin_dma_5xx.c index 36f78c1648b..bafb6aea0bc 100644 --- a/arch/blackfin/kernel/bfin_dma_5xx.c +++ b/arch/blackfin/kernel/bfin_dma_5xx.c @@ -596,11 +596,18 @@ void *dma_memcpy(void *dest, const void *src, size_t size) } EXPORT_SYMBOL(dma_memcpy); +/** + * safe_dma_memcpy - DMA memcpy w/argument checking + * + * Verify arguments are safe before heading to dma_memcpy(). + */ void *safe_dma_memcpy(void *dest, const void *src, size_t size) { - void *addr; - addr = dma_memcpy(dest, src, size); - return addr; + if (!access_ok(VERIFY_WRITE, dst, size)) + return NULL; + if (!access_ok(VERIFY_READ, src, size)) + return NULL; + return dma_memcpy(dst, src, size); } EXPORT_SYMBOL(safe_dma_memcpy);