From patchwork Wed Sep 20 08:45: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: 9961151 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 AA9256056A for ; Wed, 20 Sep 2017 08:45:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C1EB2902D for ; Wed, 20 Sep 2017 08:45:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90CFB2902E; Wed, 20 Sep 2017 08:45:29 +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 667FB29031 for ; Wed, 20 Sep 2017 08:45:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 355086E6EF; Wed, 20 Sep 2017 08:45:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x230.google.com (mail-wr0-x230.google.com [IPv6:2a00:1450:400c:c0c::230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 724E96E6EC for ; Wed, 20 Sep 2017 08:45:17 +0000 (UTC) Received: by mail-wr0-x230.google.com with SMTP id l22so1519817wrc.10 for ; Wed, 20 Sep 2017 01:45:17 -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=YWu7oW5DbBVIxPkXEvycXt1QPWIQTSnf6pe+Sf0NXR3IjOkUaRco7TP1EAuf3OGNXH L1LhlUTxYLLEeZOTPtQxhFRfz+WXfuPABk9kOc86iP7HGiAfQpQQxjuYVuLJ7jBxN3aR fw2gIX/pjp//cyK0pu/pzeDG5m9/nAH24EOYI= 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=cxmYfHUDq8OUVBaE7LEvMbLbs23Srf05excsn5l0jaElraGs6yCQN/itHq8vHVpnLM s2zC3uKeHgobKcuXrESXIu/Rf0bUOX7+I+WRmIW/rJxPqU5q7nFr9jjMSGMKwZTMrHH+ PntnnMUcm3Ftnl59pM/S2McyoONTyTjusg2VbDQPZulFRz7GWpbR8hGmZnboIgsoutTf Nz/VejOvmDYn/VkZ7WKEr4MHDUArVAtVg6IKOBzsjPzxzOB3zpWxR2+gWDV1hLkX8mV4 68vumUQGsO4bVXRBv2Eun3korltVPCmn1J/dciKahVi7f+na5Z8SnJ7au7C7SI4YNQLA xwuA== X-Gm-Message-State: AHPjjUiFuYvAp41DJKoC9hvQGQO8Ujlj1jwKk2X6+F+RpD9YGgrgnUBO qxBmm94qGe+B9wzPeFcQVGg9Bw== X-Google-Smtp-Source: AOwi7QBzMfLqnzjB6EF9ayeFNvfh/x3U+ZYLpk2LPu0J6+WzXOQPWZZGlwTG+4tjdKzJiYhFoLzsaQ== X-Received: by 10.223.164.200 with SMTP id h8mr4085281wrb.58.1505897116079; Wed, 20 Sep 2017 01:45:16 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.133.231]) by smtp.gmail.com with ESMTPSA id w9sm1188700wre.58.2017.09.20.01.45.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Sep 2017 01:45:15 -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 v3 1/2] staging: ion: simplify ioctl args checking function Date: Wed, 20 Sep 2017 10:45:04 +0200 Message-Id: <1505897105-23721-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505897105-23721-1-git-send-email-benjamin.gaignard@linaro.org> References: <1505897105-23721-1-git-send-email-benjamin.gaignard@linaro.org> Cc: devel@driverdev.osuosl.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 */