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: 114366 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp5034009qgf; Wed, 27 Sep 2017 06:20:29 -0700 (PDT) X-Received: by 10.98.60.71 with SMTP id j68mr1342698pfa.264.1506518429336; Wed, 27 Sep 2017 06:20:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506518429; cv=none; d=google.com; s=arc-20160816; b=svLOzTiL36HnUdgh/MxEtN9JMVWQ3Rs4t4pl3j9QC1RPuIMEsAzO6szu1k/2i6xz1L uazGfy0vdtjCX4m+S2AV2PstKHMP7ui3j5b9Bf1ASgQ9DjRb7Te/aPMksC3ZlQ85ZYbu yHwtvWDERadxqpa1SS2ruWpI9zM3jW4sB8LM384zAHhlQFDRkJ0aUPkb8JXmTZCdjUiL Ohhra7+nbCECGDXRk8ueeyOTvVWEpxrxDf9lVGS492WR8FtlsmMyz9CQj+9a+nB37Qx6 kmcnnNLq/x81dWofDGyC0qSSqjZQ28gl37w2ZCi+hm/sv9o4BjX2E3gWp8EDtQK7wbf7 TQ1g== 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=zQ4L5HXo70q84ZoKEVIJqqMPNkRw18hJWf+vznwoLps=; b=LF0Qa2LxeavM5F2LhXc/kEo7cSvDqK4abKW5YCwR7JX/2/7lf+CFmDq3gSMs6/Fe97 ZxgIWdDXbFNl1V7NIcG1JriXsMUFzQKMn0yZE3VYjRH3eLOxSKqEQb+JMJ0yKIGZOEaF DBpK2Sf3CAf0qIrZ9BETL0CMfPZI+Iwxqm1vBASTWorVDP31Nu7UV1u+DdmY4MXSCv1r aBk/Co4hdS5pBnuuqOP9dRe9VxZERa9eOHnWDtlICUvS3AN0o+qWKI8TtXawsY8pW/5N zXuRm6ug8FFc5LpSqGbcRyYuEGrGewjDw6xoJVbDAfe8s3TIF5acDE8bqTyrd8X7/Rn3 EWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kdtGiW53; 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 m14si7565976pgs.511.2017.09.27.06.20.28; Wed, 27 Sep 2017 06:20:29 -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=kdtGiW53; 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 S1753015AbdI0NU0 (ORCPT + 26 others); Wed, 27 Sep 2017 09:20:26 -0400 Received: from mail-wm0-f43.google.com ([74.125.82.43]:50967 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752602AbdI0NUX (ORCPT ); Wed, 27 Sep 2017 09:20:23 -0400 Received: by mail-wm0-f43.google.com with SMTP id b195so18188214wmb.5 for ; Wed, 27 Sep 2017 06:20:22 -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=ROm/ZSs5N84mDTrfWvOw0zsUSbSHkyU6FHA6Z1tAAVPn0kWENjvJ+jyWPp7sLN+W9w 3ETMPlsvtQi3ZLJENBl636DSxVG3XwVddCJHZkjmIeTv+MNj6L7HQuCUyzw3/W2biO5Z ocRPI+XBazhK4D+vK7m4ytFU8X32NJzrb810CKibKhkyUAzcFLgUa0G3u12+y3tP+sXf /czbguqW4sbcZBp0OuMTni2tBeWV9biwjJRho40AUws0aqIyxR/rfgpn3521sqF1v6z5 g2H2XaoOvR7qDJoX+YQXxx7QVhG5l3/dtpWqhGW42s7G85cKwIP2xBDTzU9j5X/AjkG9 bN4g== X-Gm-Message-State: AHPjjUhAt57Ch9gx/egwuztBZccOAsRnmlRdscCKXaeYVuXcu9gk9N23 ixeZ8XtPaPLgVNrStYuJG02cPw== 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 Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, Benjamin Gaignard 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> 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 */