]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Blackfin arch: check pointers in safe_dma_memcpy
authorMike Frysinger <vapier.adi@gmail.com>
Wed, 7 Jan 2009 15:14:38 +0000 (23:14 +0800)
committerBryan Wu <cooloney@kernel.org>
Wed, 7 Jan 2009 15:14:38 +0000 (23:14 +0800)
Check pointers in safe_dma_memcpy as this is the entry point for user-space code

Signed-off-by: Mike Frysinger <vapier.adi@gmail.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
arch/blackfin/kernel/bfin_dma_5xx.c

index 36f78c1648b9037f0a82babfb3216821c1089f1b..bafb6aea0bc5660c2fcf5a4952fa5700b9f6d88f 100644 (file)
@@ -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);