From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755343AbdJIQpP (ORCPT ); Mon, 9 Oct 2017 12:45:15 -0400 Received: from mail-qt0-f175.google.com ([209.85.216.175]:52155 "EHLO mail-qt0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755298AbdJIQpM (ORCPT ); Mon, 9 Oct 2017 12:45:12 -0400 X-Google-Smtp-Source: AOwi7QDrXOun9mEXNFRjnWRnZrnDgE27Fn4Nc1fjFRcpaau1QW0u9QyoAMi2zNKGn15itib9Zp9bVQ== Subject: Re: [PATCH v5 1/2] staging: ion: simplify ioctl args checking function To: Benjamin Gaignard , Sumit Semwal , Greg Kroah-Hartman , =?UTF-8?Q?Arve_Hj=c3=b8nnev=c3=a5g?= , Riley Andrews , Mark Brown , Dan Carpenter Cc: driverdevel , Linux Kernel Mailing List , "dri-devel@lists.freedesktop.org" , linux-api@vger.kernel.org References: <1506518409-16887-1-git-send-email-benjamin.gaignard@linaro.org> <1506518409-16887-2-git-send-email-benjamin.gaignard@linaro.org> From: Laura Abbott Message-ID: <21cdb12c-efe5-a7f5-3939-01fa9ff20b56@redhat.com> Date: Mon, 9 Oct 2017 09:45:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/09/2017 02:21 AM, Benjamin Gaignard wrote: > 2017-09-27 15:20 GMT+02:00 Benjamin Gaignard : >> 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 > Yes, this looks better. Acked-by: Laura Abbott >> Signed-off-by: Benjamin Gaignard >> --- >> 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 >> > > >