diff mbox

v4l2-ctrls: avoid a sparse complain due to __user ptr

Message ID 3de557fce274288343f3ac7f5b3e0dac87f123bf.1409786360.git.m.chehab@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mauro Carvalho Chehab Sept. 3, 2014, 11:19 p.m. UTC
c->ptr was already copied to Kernelspace. So, this sparse warning
is bogus:

>> drivers/media/v4l2-core/v4l2-ctrls.c:1685:15: sparse: incorrect type in assignment (different address spaces)
   drivers/media/v4l2-core/v4l2-ctrls.c:1685:15:    expected void *[assigned] p
   drivers/media/v4l2-core/v4l2-ctrls.c:1685:15:    got void [noderef] <asn:1>*ptr

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Comments

Hans Verkuil Sept. 4, 2014, 6:14 a.m. UTC | #1
On 09/04/2014 01:19 AM, Mauro Carvalho Chehab wrote:
> c->ptr was already copied to Kernelspace. So, this sparse warning
> is bogus:
> 
>>> drivers/media/v4l2-core/v4l2-ctrls.c:1685:15: sparse: incorrect type in assignment (different address spaces)
>    drivers/media/v4l2-core/v4l2-ctrls.c:1685:15:    expected void *[assigned] p
>    drivers/media/v4l2-core/v4l2-ctrls.c:1685:15:    got void [noderef] <asn:1>*ptr
> 
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

Nacked-by: Hans Verkuil <hans.verkuil@cisco.com>

Unfortunately, c->ptr can be a true user pointer. For once, this sparse warning
points to a real bug. It's not that easy to fix and I will need to think some
more how this should be handled.

Regards,

	Hans

> 
> diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
> index 35d1f3d5045b..ed10e4a9318c 100644
> --- a/drivers/media/v4l2-core/v4l2-ctrls.c
> +++ b/drivers/media/v4l2-core/v4l2-ctrls.c
> @@ -1682,7 +1682,7 @@ static int validate_new(const struct v4l2_ctrl *ctrl,
>  			break;
>  		}
>  	}
> -	ptr.p = c->ptr;
> +	ptr.p = (__force void *)c->ptr;
>  	for (idx = 0; !err && idx < c->size / ctrl->elem_size; idx++)
>  		err = ctrl->type_ops->validate(ctrl, idx, ptr);
>  	return err;
> 

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

Patch

diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 35d1f3d5045b..ed10e4a9318c 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -1682,7 +1682,7 @@  static int validate_new(const struct v4l2_ctrl *ctrl,
 			break;
 		}
 	}
-	ptr.p = c->ptr;
+	ptr.p = (__force void *)c->ptr;
 	for (idx = 0; !err && idx < c->size / ctrl->elem_size; idx++)
 		err = ctrl->type_ops->validate(ctrl, idx, ptr);
 	return err;