From patchwork Mon Oct 23 15:55:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 10022733 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 9877160381 for ; Mon, 23 Oct 2017 15:57:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ABAC205AF for ; Mon, 23 Oct 2017 15:57:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F77428700; Mon, 23 Oct 2017 15:57:00 +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 EF351205AF for ; Mon, 23 Oct 2017 15:56:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF8B06E3A4; Mon, 23 Oct 2017 15:56:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC2106E3A4 for ; Mon, 23 Oct 2017 15:56:57 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id u138so10468443wmu.5 for ; Mon, 23 Oct 2017 08:56:57 -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=2/ZSUiaLvDjbtqFalwueybAZ2zE86dsVHj2EaZ+fLOA=; b=fff0wE3BxoCoAK+vWQri5na85zrtKg2CYgBbmaOnpRayeyRm09CoRhjpX9mEL7WgbA lz8pxPEeqNTCd7mNCf3xLwJKyjaS0KrFzpqr0EEbsq1UVC+ZjZSRJhIyVFDhLzkqbILo 0XirQJlbW5S79iyQDqmG7WmGv8eDh3dyFAzH0= 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=2/ZSUiaLvDjbtqFalwueybAZ2zE86dsVHj2EaZ+fLOA=; b=kT/N/0dO58eA90teIdPON93dn5qsBTzfwaJK2awHe51uBlyTkyMkjPWcrRnDNkbFaN 3y4DmPwuld0A0ljFL9bh4ASbWrwYJUlquB9cSBG0/MSHzG+9OD5fY77WV71dMZaj1M3c vmqWvW0FeovhnHieEOOnZaLBEc3tIRjPbrKTF6kmZG4fn7FH21DlCQy8unAapvQ/ww8Y hOi0Ywe4UMOgGuGJaEFOyrQpAo3Q4+HYCjofHJ7LexoQX/ZvPxgP0pVyscBvdcZRoIxj eKcUu3x7mAnnRxHs3pjnORq+bLk0lZ055MC8bs+PBhPvnZfxUsM78S1vhxHNnx3jr6qW jHpQ== X-Gm-Message-State: AMCzsaWLYsN3/qCutNv5Ti17W5ZBhheGpERUN73wrRUMwX8aWMqTLnor hXJuLhehatxmPSRs80PZe1C72g== X-Google-Smtp-Source: ABhQp+SWDV+aUUGDQtZtOgyj2R2hlxzfmH9U6w3UPPxtwLAfIJ2Ei8J3IscPPewHz9YuOHOkQh6GIA== X-Received: by 10.28.6.14 with SMTP id 14mr5412905wmg.37.1508774216138; Mon, 23 Oct 2017 08:56:56 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.214.19.18]) by smtp.gmail.com with ESMTPSA id 55sm8717335wrw.60.2017.10.23.08.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 08:56:55 -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 v6 1/2] staging: ion: simplify ioctl args checking function Date: Mon, 23 Oct 2017 17:55:36 +0200 Message-Id: <1508774137-13835-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508774137-13835-1-git-send-email-benjamin.gaignard@linaro.org> References: <1508774137-13835-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 */