From: Hans Verkuil <hans.verk...@cisco.com>

Fix the use of __user in the check_array_args() prototype: instead of
using 'void * __user *' you should use 'void __user **' for sparse to
understand this correctly.

This also required the use of __force in the '*kernel_ptr = user_ptr'
assignment.

Also replace a wrong cast (void *) with the correct one (void **)
in check_array_args().

This fixes these sparse warnings:

drivers/media/v4l2-core/v4l2-ioctl.c:2284:35: warning: incorrect type in 
assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2301:35: warning: incorrect type in 
assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2319:35: warning: incorrect type in 
assignment (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2386:57: warning: incorrect type in 
argument 4 (different address spaces)
drivers/media/v4l2-core/v4l2-ioctl.c:2420:29: warning: incorrect type in 
assignment (different address spaces)

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index d9113cc..f729bd2 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -2260,7 +2260,7 @@ done:
 }
 
 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
-                           void * __user *user_ptr, void ***kernel_ptr)
+                           void __user **user_ptr, void ***kernel_ptr)
 {
        int ret = 0;
 
@@ -2277,7 +2277,7 @@ static int check_array_args(unsigned int cmd, void *parg, 
size_t *array_size,
                                break;
                        }
                        *user_ptr = (void __user *)buf->m.planes;
-                       *kernel_ptr = (void *)&buf->m.planes;
+                       *kernel_ptr = (void **)&buf->m.planes;
                        *array_size = sizeof(struct v4l2_plane) * buf->length;
                        ret = 1;
                }
@@ -2294,7 +2294,7 @@ static int check_array_args(unsigned int cmd, void *parg, 
size_t *array_size,
                                break;
                        }
                        *user_ptr = (void __user *)edid->edid;
-                       *kernel_ptr = (void *)&edid->edid;
+                       *kernel_ptr = (void **)&edid->edid;
                        *array_size = edid->blocks * 128;
                        ret = 1;
                }
@@ -2312,7 +2312,7 @@ static int check_array_args(unsigned int cmd, void *parg, 
size_t *array_size,
                                break;
                        }
                        *user_ptr = (void __user *)ctrls->controls;
-                       *kernel_ptr = (void *)&ctrls->controls;
+                       *kernel_ptr = (void **)&ctrls->controls;
                        *array_size = sizeof(struct v4l2_ext_control)
                                    * ctrls->count;
                        ret = 1;
@@ -2412,7 +2412,7 @@ video_usercopy(struct file *file, unsigned int cmd, 
unsigned long arg,
        }
 
        if (has_array_args) {
-               *kernel_ptr = user_ptr;
+               *kernel_ptr = (void __force *)user_ptr;
                if (copy_to_user(user_ptr, mbuf, array_size))
                        err = -EFAULT;
                goto out_array_args;
-- 
1.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to