Skip to contentSkip to conversation

staging: binder: add __user annotation in binder.c

PATCH RESEND In review Mathieu Maret 3 participants 7 messages Apr 15, 2014 – Apr 17, 2014 Staging

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/2 staging: binder: add __user annotation in binder.c

Add __user to binder_version to correct sparse warning. Reduce line size to fit to coding style.

---
 drivers/staging/android/binder.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/staging/android/binder.c +6 -2
index cfe4bc8..3dca577 100644
@@ -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;
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH RESEND 2/2 staging: binder: Code simplification

Remove duplicate code

---
 drivers/staging/android/binder.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/android/binder.c +2 -5
index 3dca577..c29c3c7 100644
@@ -2686,11 +2686,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	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,
+		if (size != sizeof(struct binder_version) ||
+		    put_user(BINDER_CURRENT_PROTOCOL_VERSION,
 			     &ver->protocol_version)) {
 			ret = -EINVAL;
 			goto err;
Signature · 1 line
1.8.3.2
#2 lore raw

Re: [PATCH RESEND 2/2] staging: binder: Code simplification

Quoted 2 lines · Mathieu Maret

Remove duplicate code

The original code is simpler actually.

regards,
dan carpenter

maintainer
#3 lore raw

Re: [PATCH RESEND 2/2] staging: binder: Code simplification

In reply to Mathieu Maret
Quoted 15 lines · Mathieu Maret

Remove duplicate code

---
 drivers/staging/android/binder.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/android/binder.c +0 -0
index 3dca577..c29c3c7 100644
@@ -2686,11 +2686,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	case BINDER_VERSION:{
 		struct binder_version __user *ver = ubuf;
 

drivers/staging/android/binder.c static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) · line 2693

Quoted 10 lines
drivers/staging/android/binder.c +2 -5
-		if (size != sizeof(struct binder_version)) {
-			ret = -EINVAL;
-			goto err;
-		}
-		if (put_user(BINDER_CURRENT_PROTOCOL_VERSION,
+		if (size != sizeof(struct binder_version) ||
+		    put_user(BINDER_CURRENT_PROTOCOL_VERSION,
 			     &ver->protocol_version)) {
 			ret = -EINVAL;
 			goto err;

I agree with Dan, the original code was easier to read.

thanks,

greg k-h

#5 lore raw
Quoted 2 lines · Dan Carpenter

This is the first time you have sent it to the list, it's not a RESEND.

The first one was only on the linux-kernel mailing list. May be, that's why you did not get it.
As it was just before the 3.14 release, I was asked to resend latter.

Is it the expected meaning of the "RESEND" tag?

Quoted 1 line

Patch looks ok.

Cool

Quoted 4 lines

regards,
dan carpenter

Regards,
Mathieu

#6 lore raw
Quoted 4 lines · Mathieu Maret
Quoted 2 lines · Dan Carpenter

This is the first time you have sent it to the list, it's not a RESEND.

The first one was only on the linux-kernel mailing list.

Oh. No one reads lkml. It's just for the google archive.

regards,
dan carpenter