linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: binder: add __user annotation in binder.c
@ 2014-03-25  0:24 Mathieu Maret
  2014-03-25  0:24 ` [PATCH 2/2] staging: binder: reduce line size Mathieu Maret
  2014-03-25  0:51 ` [PATCH 1/2] staging: binder: add __user annotation in binder.c Joe Perches
  0 siblings, 2 replies; 4+ messages in thread
From: Mathieu Maret @ 2014-03-25  0:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: arve, gregkh, Mathieu Maret

Fix the following spare warning
drivers/staging/android/binder.c:2691:21: warning: incorrect type in argument 1 (different address spaces)

Signed-off-by: Mathieu Maret <mathieu.maret@gmail.com>
---
 drivers/staging/android/binder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index cfe4bc8..9418086 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2688,7 +2688,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			ret = -EINVAL;
 			goto err;
 		}
-		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
+		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version __user *)ubuf)->protocol_version)) {
 			ret = -EINVAL;
 			goto err;
 		}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] staging: binder: reduce line size
  2014-03-25  0:24 [PATCH 1/2] staging: binder: add __user annotation in binder.c Mathieu Maret
@ 2014-03-25  0:24 ` Mathieu Maret
  2014-03-25  0:51 ` [PATCH 1/2] staging: binder: add __user annotation in binder.c Joe Perches
  1 sibling, 0 replies; 4+ messages in thread
From: Mathieu Maret @ 2014-03-25  0:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: arve, gregkh, Mathieu Maret

Signed-off-by: Mathieu Maret <mathieu.maret@gmail.com>
---
 drivers/staging/android/binder.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 9418086..4e51034 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2688,7 +2688,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			ret = -EINVAL;
 			goto err;
 		}
-		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version __user *)ubuf)->protocol_version)) {
+		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
+			&((struct binder_version __user *)ubuf)->protocol_version)) {
 			ret = -EINVAL;
 			goto err;
 		}
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] staging: binder: add __user annotation in binder.c
  2014-03-25  0:24 [PATCH 1/2] staging: binder: add __user annotation in binder.c Mathieu Maret
  2014-03-25  0:24 ` [PATCH 2/2] staging: binder: reduce line size Mathieu Maret
@ 2014-03-25  0:51 ` Joe Perches
  2014-03-25  0:54   ` Mathieu Maret
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-03-25  0:51 UTC (permalink / raw)
  To: Mathieu Maret; +Cc: linux-kernel, arve, gregkh

On Tue, 2014-03-25 at 01:24 +0100, Mathieu Maret wrote:
> Fix the following spare warning

sparse

> drivers/staging/android/binder.c:2691:21: warning: incorrect type in argument 1 (different address spaces)
[]
> diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
[]
> @@ -2688,7 +2688,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
[]
> -		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
> +		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version __user *)ubuf)->protocol_version)) {

That's certainly one way to do it, but I'd suggest
using a temporary instead

 drivers/staging/android/binder.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index cfe4bc8..1f5e249 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -2683,16 +2683,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		binder_free_thread(proc, thread);
 		thread = NULL;
 		break;
-	case BINDER_VERSION:
+	case BINDER_VERSION: {
+		struct binder_version __user *ver = ubuf;
+
 		if (size != sizeof(struct binder_version)) {
 			ret = -EINVAL;
 			goto err;
 		}
-		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
+		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
+			     &ver->protocol_version)) {
 			ret = -EINVAL;
 			goto err;
 		}
 		break;
+	}
 	default:
 		ret = -EINVAL;
 		goto err;



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] staging: binder: add __user annotation in binder.c
  2014-03-25  0:51 ` [PATCH 1/2] staging: binder: add __user annotation in binder.c Joe Perches
@ 2014-03-25  0:54   ` Mathieu Maret
  0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Maret @ 2014-03-25  0:54 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, arve, gregkh

Joe Perches wrote:
> On Tue, 2014-03-25 at 01:24 +0100, Mathieu Maret wrote:
> > Fix the following spare warning
> 
> sparse
> 
> > drivers/staging/android/binder.c:2691:21: warning: incorrect type in argument 1 (different address spaces)
> []
> > diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
> []
> > @@ -2688,7 +2688,7 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> []
> > -		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
> > +		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version __user *)ubuf)->protocol_version)) {
> 
> That's certainly one way to do it, but I'd suggest
> using a temporary instead
> 
>  drivers/staging/android/binder.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
> index cfe4bc8..1f5e249 100644
> --- a/drivers/staging/android/binder.c
> +++ b/drivers/staging/android/binder.c
> @@ -2683,16 +2683,20 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
>  		binder_free_thread(proc, thread);
>  		thread = NULL;
>  		break;
> -	case BINDER_VERSION:
> +	case BINDER_VERSION: {
> +		struct binder_version __user *ver = ubuf;
> +
>  		if (size != sizeof(struct binder_version)) {
>  			ret = -EINVAL;
>  			goto err;
>  		}
> -		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION, &((struct binder_version *)ubuf)->protocol_version)) {
> +		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
> +			     &ver->protocol_version)) {
>  			ret = -EINVAL;
>  			goto err;
>  		}
>  		break;
> +	}
>  	default:
>  		ret = -EINVAL;
>  		goto err;
> 
>
And you solve the issue with the line size btw.
Good move!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-25  0:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-25  0:24 [PATCH 1/2] staging: binder: add __user annotation in binder.c Mathieu Maret
2014-03-25  0:24 ` [PATCH 2/2] staging: binder: reduce line size Mathieu Maret
2014-03-25  0:51 ` [PATCH 1/2] staging: binder: add __user annotation in binder.c Joe Perches
2014-03-25  0:54   ` Mathieu Maret

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).