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: 116741 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4801045qgn; Mon, 23 Oct 2017 08:57:01 -0700 (PDT) X-Received: by 10.101.86.201 with SMTP id w9mr12073671pgs.191.1508774221040; Mon, 23 Oct 2017 08:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508774221; cv=none; d=google.com; s=arc-20160816; b=cMh0J+wsOUVw+t7naInRnbH0+QKyWuGEHL9fRAONR5TQwaDUCCamDc8wgmLMhSmkiS C3n3rKn1SqAVdC8R0l0ixHhj0zIPV6WrVkP/52ZGH06OtGudWjMeLfbSvP8O3PVlz2hR yCzwd3uRcxIbBBclBDu4m5Rx3BygaN4s23au8gBld7m1TmuGvO64WdfoDKwEtXYDv8XY 0kWKn3PFAmVjn95BMgHX3p86te5va8n2syYijtDPJid/w82nNjL+Pk44DrYd8Ac9fYCY HILt04Fy7tshrE5vF69cowxeDZlwOlGzQaneWGFTW5+EQjkptj7i8+NIA1zxu8og5qJL Gcqg== 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=2/ZSUiaLvDjbtqFalwueybAZ2zE86dsVHj2EaZ+fLOA=; b=gLIQgDe39yv9hSpAiodUwz/ghgHIn76h7aS+cqb7eYRTfkqNwKvdOpl4R2Jg6U1IHE DrCUEGlwngwRsZz4oPd9Abu2ffdMJ2zeBu1QWuFpvjeAxrmJ5zN/5n7pEueJfTClZW7C sN1v8YxFpA/AvdosGrdeG2rbLGLHy5qo+xKnwpvTQ9DWbRYdcEO42yq39TT7+sVCCexa 4vgucB6iL5zA/M+jfQaU1JEtq0xV1VNPhRPw6e5+S4AsohxxwFK3e07Dzr69cT3g4KjQ BkmnclMIXttxzrrIFWqS30BbfkvFlCQUAd82PjDNofRn0sIMF5N7JyXi31DHdKhUBNTG Kixw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fff0wE3B; 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 x23si5063344pgc.683.2017.10.23.08.57.00; Mon, 23 Oct 2017 08:57:01 -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=fff0wE3B; 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 S932365AbdJWP46 (ORCPT + 27 others); Mon, 23 Oct 2017 11:56:58 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:45563 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932274AbdJWP45 (ORCPT ); Mon, 23 Oct 2017 11:56:57 -0400 Received: by mail-wm0-f66.google.com with SMTP id q124so10503172wmb.0 for ; Mon, 23 Oct 2017 08:56:56 -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=ICls+hLgy1d1WU3c2zZLhkVlyjVxnvEbRAHWwBgMPp2zD/bS46bqqFqi5eNybmz0fm KOps3hrvC7WceeY5WN5M09l0jvJla3xCWXWqILTYzxDOIQ+NI8VOAVQiEkOhVQhk5ATA SYkRI0QikYBmQdEcLxDdbUeK6vdI71mmdR8V2zSzz9xHs7UmYkYzIf2FSmNt4kZ12U7M cx0g0eb4O9XiUog2EZ/5ppgoL+0wIyG2TWaSzxKMwZ5MXdgHd4spK9EOY4uyOObCDEM3 8fTxALG+LUJeZjSfgTvZBzp8kKPBy8peziRnVSDxWtSSoP0HNjGhlfFnRGs0pgILjow4 m/DQ== X-Gm-Message-State: AMCzsaWr32J4ygnImsL9aM7suM5aff5IqclHHP6QCsptXX/5T9dSFWlN VOE0YhPs3lWeTQ3JOxoTEV0wOA== 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 Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, Benjamin Gaignard 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> 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 Acked-by: Laura Abbott --- 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 */