[PATCH 3/4] driver/memmap: fix generic_memmap_rw and generic_memmap_ro

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Wed Feb 9 22:31:59 EST 2011


we check before the RW access for generic_memmap_ro instead of
generic_memmap_rw

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/base/driver.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index ff92e44..bd7464e 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -223,8 +223,6 @@ int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
 	if (!cdev->dev)
 		return -EINVAL;
 
-	if (flags & PROT_WRITE)
-		return -EACCES;
 	*map = (void *)cdev->dev->map_base;
 	return 0;
 }
@@ -234,6 +232,9 @@ int generic_memmap_rw(struct cdev *cdev, void **map, int flags)
 	if (!cdev->dev)
 		return -EINVAL;
 
+	if (flags & PROT_WRITE)
+		return -EACCES;
+
 	*map = (void *)cdev->dev->map_base;
 	return 0;
 }
-- 
1.7.2.3




More information about the barebox mailing list