Staging: gdm72xx: Fix sparse warning
PATCH 1/1 Staging: gdm72xx: Fix sparse warning
Calls copy_{to,from}_user() do not use '__user' annotation while refrencing user space pointers.
Fix following sparse warnings by passing missing __user annotation:
drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in argument 1 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
<asn:1>*todrivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *bufdrivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in argument 2 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
[noderef] <asn:1>*fromdrivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *buf
--- drivers/staging/gdm72xx/gdm_wimax.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/gdm72xx/gdm_wimax.c +2 -2
@@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)if (src->size) {if (!dst->buf)return -EINVAL ; -if (copy_to_user (dst->buf, src->buf, size)) +if (copy_to_user ((void __user *)dst->buf, src->buf, size))return -EFAULT ; }return 0 ;
@@ -401,7 +401,7 @@ static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)return -ENOMEM ; } -if (copy_from_user (dst->buf, src->buf, src->size)) { +if (copy_from_user (dst->buf, (void __user *)src->buf, src->size)) {kdelete (&dst->buf);return -EFAULT ; }
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 26 lines · Ksenija Stanojevic
Calls copy_{to,from}_user() do not use '
__user' annotation while refrencing user space pointers.Fix following sparse warnings by passing missing
__userannotation:
drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in argument 1 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
<asn:1>*todrivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *bufdrivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in argument 2 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
[noderef] <asn:1>*fromdrivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *bufSigned-off-by Ksenija Stanojevic <[email protected]>--- drivers/staging/gdm72xx/gdm_wimax.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/gdm72xx/gdm_wimax.c +0
-0
drivers/staging/gdm72xx/gdm_wimax.c static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src) · line 381
Quoted 5 lines
drivers/staging/gdm72xx/gdm_wimax.c +1
-1@@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)if (src->size) {if (!dst->buf)return -EINVAL ; -if (copy_to_user (dst->buf, src->buf, size)) +if (copy_to_user ((void __user *)dst->buf, src->buf, size))
Shouldn't the variable be described as a __user pointer instead? Don't cast away warnings, fix the root problem.
thanks,
greg k-h
Quoted 22 lines · Greg KH
Quoted 21 lines · Ksenija Stanojevic
Calls copy_{to,from}_user() do not use '
__user' annotation while refrencing user space pointers.Fix following sparse warnings by passing missing
__userannotation:
drivers/staging/gdm72xx/gdm_wimax.c:381:37: warning: incorrect type in argument 1 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:381:37: expected void [noderef]
<asn:1>*todrivers/staging/gdm72xx/gdm_wimax.c:381:37: got void *bufdrivers/staging/gdm72xx/gdm_wimax.c:404:41: warning: incorrect type in argument 2 (different address spaces)drivers/staging/gdm72xx/gdm_wimax.c:404:41: expected void const
[noderef] <asn:1>*fromdrivers/staging/gdm72xx/gdm_wimax.c:404:41: got void *bufSigned-off-by Ksenija Stanojevic <[email protected]>--- drivers/staging/gdm72xx/gdm_wimax.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
drivers/staging/gdm72xx/gdm_wimax.c static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src) · line 381
Quoted 10 lines
drivers/staging/gdm72xx/gdm_wimax.c +1
-1@@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)if (src->size) {if (!dst->buf)return -EINVAL ; -if (copy_to_user (dst->buf, src->buf, size)) +if (copy_to_user ((void __user *)dst->buf, src->buf, size))Shouldn't the variable be described as a
__userpointer instead? Don't cast away warnings, fix the root problem.
I don't think so because dst and src are both pointers to struct data_s and dst->buf in one function used as user buffer and in the next one as a kernel buffer. Same goes for src-buf.
struct data_s {
int size;
void *buf;
};Quoted 15 lines · On Wednesday 04 November 2015 11:14:54 Ksenija Stanojević wrote:
Quoted 14 lines
drivers/staging/gdm72xx/gdm_wimax.c static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src) · line 381
Quoted 11 lines
drivers/staging/gdm72xx/gdm_wimax.c +1
-1@@ -378,7 +378,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)if (src->size) {if (!dst->buf)return -EINVAL ; -if (copy_to_user (dst->buf, src->buf, size)) +if (copy_to_user ((void __user *)dst->buf, src->buf, size))Shouldn't the variable be described as a
__userpointer instead? Don't cast away warnings, fix the root problem.
Quoted 9 lines
I don't think so because dst and src are both pointers to struct
data_sanddst->bufin one function used as user buffer and in the next one as a kernel buffer. Same goes for src-buf.struct data_s { int size; void *buf; };
I think this should be two separate structures, one for the user-space data and one for the kernel side.
Arnd