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: 9971819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5F855602BD for ; Tue, 26 Sep 2017 12:07:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4470E288E4 for ; Tue, 26 Sep 2017 12:07:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 392EE28B45; Tue, 26 Sep 2017 12:07:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C1DD028CE9 for ; Tue, 26 Sep 2017 12:07:48 +0000 (UTC) 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 */