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: 113087 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp426379edb; Wed, 20 Sep 2017 01:45:27 -0700 (PDT) X-Received: by 10.99.98.68 with SMTP id w65mr1440596pgb.234.1505897127799; Wed, 20 Sep 2017 01:45:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505897127; cv=none; d=google.com; s=arc-20160816; b=vSMVy6GEvVh2TXLNfs+h4KvUYbN9v4HHeJ0V6IzfYUczVQp4nvKaCKizkBEYfXV5ep 1qbcMQRniWER4ilik1Kn00AEk8KD0S8rxxMFLQajb5VhF93zPhmj46Uq1f/OdsIu6EB5 joQh47YYeRzzMMNhFLfd0J7Z12qdao4+wAaHwXuCeVh5Sj6yy4Zd4EcvPwahlvL2KLku VHimuzoK70XDaIaTXZaQ9y8Xv1QUPh8pSMFeMoEFdHPc1XWr5J0q894dvH8WPKlsGuwl sEHdI1DcguqMUE7gpx5LHwhKAZ5yPVbi6tmgDC3fmr8eSC38vcvBiKQvTJDVF/h0Z0qC hIzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=E3q4+DnoJTevrgOB3IhP71fBhH7C18Z06tfGTavzLvI=; b=EuhiagrvmADmLAdTzd/P5rw4VSB/YdxUjm2A3//Md99DMHJZcnFjQBzRMStxQE/HxU +PxytMSMzGkNj9P6EOsuuuPW5hnX1KptFsJWDsUPWNyycXnfOzpR0fXpCDj3Vvr/ZR3i wvHHEsbeBqnqkGkDW2I13/+DN43dJVYFJUSl5e+ul4jeBs93vjRqugrTr68CFxkPvMGy TxR/Hu7LM5GLsZcTzR/1fp/idIw6J9O0RvEgnwohB1GSnl4C27H/RJA1yraffyRcmwoQ hySG+FUjBdnHD+38XxTnH8ZN+xL9Dc8zLvPpWsFOe217KxcYAQMyEbb6dff//JGPRvMl lbhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YWu7oW5D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o89si2709864pfj.18.2017.09.20.01.45.27; Wed, 20 Sep 2017 01:45:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YWu7oW5D; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751669AbdITIpX (ORCPT + 26 others); Wed, 20 Sep 2017 04:45:23 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:44599 "EHLO mail-wr0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbdITIpR (ORCPT ); Wed, 20 Sep 2017 04:45:17 -0400 Received: by mail-wr0-f179.google.com with SMTP id v109so1525125wrc.1 for ; Wed, 20 Sep 2017 01:45:16 -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=ks6s9QTrajB8oE8Y0ChUDVwrgViAWvZ3oWu6UUl8jStwfnLYYxwt1JIG3mfDiSQazc IkaufS9kIU6zSj4RaZD0qeph3Ocmp/wLujcyfbEdlcZhFGiNb2ZPdgWb/lZkr6YF+v30 pIdyNuWnay9P9XrL3nvB2rkrMAKk0S8d5epd85dA5FcWSxaPhAQh00aTjbl4yJFwZcpw kWYmmFCPSxl3uWrWVShkwbjPlFtmwfDOySnbm+YRHeb9i+KQKG25Pna+l1z23v6SZ+es WM3BUt26exRkEcEGvnqtghFVGf0k9sZWH68mgIfdfNyAqK/D4hObxd427rrxlBzFiN3A Uvzg== X-Gm-Message-State: AHPjjUiSLifhZuzIzaMsgUtNg/qH2n4mq3Z4kkcj595+8ZuCZgoa8UMO HfXEZMoaFGsfNdmSoJGmTkzPiw== 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 Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Benjamin Gaignard 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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 */