From patchwork Tue Sep 26 12:07:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 114249 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3748129qgf; Tue, 26 Sep 2017 05:07:32 -0700 (PDT) X-Received: by 10.99.122.22 with SMTP id v22mr10562941pgc.394.1506427652322; Tue, 26 Sep 2017 05:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506427652; cv=none; d=google.com; s=arc-20160816; b=0TQ/dp7cMFz4Vw8EKtlxcqG8r4QS237FsjeGfKZ7jj+m9wNrpz9uJRPOdR07+MPOpN iAyGQDIaSv8Qwf95di4LTNMvjaflhXRYwYs57UeokeJGRoyr6O2TQ9zLDK3hiPagMQQk c909HerzSFNocQAAe7Ayd0m3wpiZQumtjc/tyc//Ojpz8gFihT1cnL+pQ3Bal0Zb+Dd+ GP/P5TadiRD5X3SYKx6x9JRVz9+MMrPmjSZ9e18i3yN5mzizfJTS5xiMZVqe/ggSy5yt JhYlrltffArVC0tn0X3P1AJmK8fDwU6caHZId0RR/++XFkHGDh4zq4bUvVs4qkJZ4HpD FCkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=jtTbrnGspbIUaZToJu9YAOm4uMkk9siYcECrWOfRYgU=; b=FEBhcdAyHSTviV23Fxnxe2IhqGQgQwPJy4TBQgt1ty9srCimXxzUsqcLVZZokUnrRa yJAxU4NC2OfYWn8cG7fB/X/waHtKjiMhm2JwLl8E+my6LasOpbL9p3Fr+emaXYEzfzIi RWzy5eLEkPpCLXck/+UgXqItebgzqK5a4wWwlWohAFfHNXmcW8gZihloe5EuE/Szal4i Qe8ItntPXVDWdEtZFuzneP8NrLnUSGKytoBGp15TUBBvvPnUBe+01361J1UIAnLKRO7D VJnhMygifHAWKiJZRvjCr1FsqBEmOAAvB5gemS8bX3efSDu1pKt2KJWBWZL1armjZaZe exiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N2F3XPZa; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 10si5576989pfj.239.2017.09.26.05.07.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Sep 2017 05:07:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N2F3XPZa; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E3C596E52E; Tue, 26 Sep 2017 12:07:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com [IPv6:2a00:1450:400c:c09::235]) by gabe.freedesktop.org (Postfix) with ESMTPS id 88F986E52E for ; Tue, 26 Sep 2017 12:07:29 +0000 (UTC) Received: by mail-wm0-x235.google.com with SMTP id b195so7084952wmb.5 for ; Tue, 26 Sep 2017 05:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=E3q4+DnoJTevrgOB3IhP71fBhH7C18Z06tfGTavzLvI=; b=N2F3XPZajV6KvM2r5ctBENhJ+xKMtMINsAMIt/Nbze+WMMyYQ3u/02bKVEa91baBRJ 4XNaNXA05reA8RYkJgXViocgD4z7rlkrDsqSr5s62XnFn2xKQK2hvQrtZ+0CENMJAlT5 dXX4TLQNtVRFdquBfYXACE79JV2yop9crrl1c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=E3q4+DnoJTevrgOB3IhP71fBhH7C18Z06tfGTavzLvI=; b=FSI6n+q5PyXRDXot5u+NnVWTCpoN30I5nSrC2qcW+0BcXTDbr3iKJKwOgpaNhE/hBM /5eZOm3IR53nREYVdGKt9RrsdKuMscF6Th7VDkMv3Q9xhExKmNmE2i9mqVR2pokx+ZUa COyfWqgY1pjYiuRsWi75UvN7DLlByIb7WajXMJQKZ25q/+pKvNS0aT1OFn/LgGKS6awV txzsi8qEECdbIp9BSrkn6BRQQ4q4zE63aJ26S2WAB4C3OQEWHfskAKshoHQni/fKQ5wr SlMc3SVZtUxUVnt4dMWkjN3ePcYtcFIpuqsO5GpWWpCw535/r18F7rb1EYD9tkuXIdm5 TDtg== X-Gm-Message-State: AHPjjUhkCruJKEZ99FBeWmnd6E1nkNjLNK5rQ5rhi8ZlHWxL0zVLLop1 L0xO77yq9xCUOzLCy5x27/owlw== X-Google-Smtp-Source: AOwi7QBKHC5HizM6V8hTpTVhhSC+B6xy24oBGkwnYa4ML3tdSwzuiss8XTAN26uj7v0weccFf1WqJw== X-Received: by 10.28.218.209 with SMTP id r200mr2861957wmg.97.1506427648008; Tue, 26 Sep 2017 05:07:28 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.129.224]) by smtp.gmail.com with ESMTPSA id r6sm7815332wrg.40.2017.09.26.05.07.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 05:07:27 -0700 (PDT) From: Benjamin Gaignard To: labbott@redhat.com, sumit.semwal@linaro.org, gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, broonie@kernel.org, dan.carpenter@oracle.com Subject: [PATCH v4 1/2] staging: ion: simplify ioctl args checking function Date: Tue, 26 Sep 2017 14:07:04 +0200 Message-Id: <1506427625-19202-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506427625-19202-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506427625-19202-1-git-send-email-benjamin.gaignard@linaro.org> Cc: devel@driverdev.osuosl.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make arguments checking more easy to read. 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 */