From patchwork Wed Sep 27 13:20:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 9974035 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 A24CE602D6 for ; Wed, 27 Sep 2017 13:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9126629154 for ; Wed, 27 Sep 2017 13:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FE2D291F0; Wed, 27 Sep 2017 13:20:43 +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 9A22529154 for ; Wed, 27 Sep 2017 13:20:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 23D636E2E9; Wed, 27 Sep 2017 13:20:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 746856E245 for ; Wed, 27 Sep 2017 13:20:23 +0000 (UTC) Received: by mail-wm0-x229.google.com with SMTP id m72so18280003wmc.1 for ; Wed, 27 Sep 2017 06:20:23 -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=zQ4L5HXo70q84ZoKEVIJqqMPNkRw18hJWf+vznwoLps=; b=kdtGiW53meGrkKnaS21kvSmuHSmeWlMpZM8hPp+MBkc8NKzXTF7iIbEk2PG8fuWbya V21xSl60WncZMfkPiJBWXJtemnWkPU4LugVuq0OajuFrwcK1gXT3OZ6C1FIgd/k6oxdk 4mZh2D4Y0/REv05Jrj7mzY5ekoKOzBaCZ2vtg= 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=zQ4L5HXo70q84ZoKEVIJqqMPNkRw18hJWf+vznwoLps=; b=E7XhsJfQ8dtArHL2JNa5gR0mqo0FqvZfHA3JWkbc+T6A7MtrzhxATjXk5h6RuBhtcj fS7MI33glXPVyX6/Ug3Q8EtZheLZ9rTvGg+t2lMrauxJjEbES9nuXzhKia8kVR1NVqCq ZsWv2y8fj1LN9Pc0cSfwzI/mvGwI/Li6fstRHRM495pdubKV8GUQmKVuqfgRA9t8BGuL HhiRjoBoqF3d+DoWvv7nAJztSDILDRM9W74IO4l8CJBfe7ctwwZkDKxDXU85bYQ9DXYK +NC2ByZk7gwTkMxb0/YleSFW8oMCoRCx5APJhRZDoa9om7nJXTETHn/1qbUiBVhwoYhc z2OA== X-Gm-Message-State: AHPjjUiZiYlmjWkfrPTxKQDPnVBktPBHNsiyrvC3FD0HvooP6n12quHQ BW+QIJSRR8yXsBrSDi0TDEbf4g== X-Google-Smtp-Source: AOwi7QDHJPANCqTPedLwrdYMxu/2vSLWMWcWwfhq2c7A/DaRJT13rG7KLnzEJGyAuDDLLYzpw3vAmw== X-Received: by 10.28.135.209 with SMTP id j200mr271121wmd.40.1506518422041; Wed, 27 Sep 2017 06:20:22 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.129.76]) by smtp.gmail.com with ESMTPSA id 110sm6886002wra.39.2017.09.27.06.20.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Sep 2017 06:20:21 -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 v5 1/2] staging: ion: simplify ioctl args checking function Date: Wed, 27 Sep 2017 15:20:08 +0200 Message-Id: <1506518409-16887-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506518409-16887-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506518409-16887-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 Acked-by: Laura Abbott --- 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 */