Thread (20 messages) 20 messages, 4 authors, 2017-10-23

Re: [PATCH v5 1/2] staging: ion: simplify ioctl args checking function

flat view

From: Benjamin Gaignard <hidden>
Date: 2017-10-09 09:21:57
Also in: dri-devel, lkml

2017-09-27 15:20 GMT+02:00 Benjamin Gaignard [off-list ref]:
Make arguments checking more easy to read.
Hi Laura,

Even if we don't have found a solution for the second patch I believe
this one could be useful.
May I ask you your point of view on those few lines ?

Benjamin
quoted hunk ↗ jump to hunk
Signed-off-by: Benjamin Gaignard <redacted>
---
 drivers/staging/android/ion/ion-ioctl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c
index d9f8b14..e26b786 100644
--- a/drivers/staging/android/ion/ion-ioctl.c
+++ b/drivers/staging/android/ion/ion-ioctl.c
@@ -27,19 +27,18 @@ union ion_ioctl_arg {

 static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
 {
-       int ret = 0;
-
        switch (cmd) {
        case ION_IOC_HEAP_QUERY:
-               ret = arg->query.reserved0 != 0;
-               ret |= arg->query.reserved1 != 0;
-               ret |= arg->query.reserved2 != 0;
+               if (arg->query.reserved0 ||
+                   arg->query.reserved1 ||
+                   arg->query.reserved2)
+                       return -EINVAL;
                break;
        default:
                break;
        }

-       return ret ? -EINVAL : 0;
+       return 0;
 }

 /* fix up the cases where the ioctl direction bits are incorrect */
--
2.7.4


-- 
Benjamin Gaignard

Graphic Study Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help