From patchwork Tue Sep 19 10:25:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 112978 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4729809qgf; Tue, 19 Sep 2017 03:26:09 -0700 (PDT) X-Received: by 10.159.247.202 with SMTP id v10mr834303plz.321.1505816769339; Tue, 19 Sep 2017 03:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505816769; cv=none; d=google.com; s=arc-20160816; b=LoNWp+e9jYr3I2nA8CSKN+iB91agl3Q8gAfR9bjuOYE3i1eSbGgWMz/rvETAPMZ20Y oSkNU2YesH4n7ZrG85O8ncu0VBSErT8KypevBzEksZ8MT/BKeaE5Z22Kr97Wftr1Yd5v Smr9w8a8CXt/kg+Xu6kvpN35mbXFKOiIMTDy3eTF058c3WO9I/8YUinX62JabgaeJAu9 cuQJyfBvYzW2oU3xeS658B0BkjgV3JLY6wNOqxFOSz02kcqqLh0XqUHxYtI3qlJXjhMi Z2JLLtXKStBGdngRSMd6xgEOhs/ds/LvKG/uASXVvq8vE6YEbzxZrUpRSI1G+lTNYjXf ZFGA== 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=imJiFXKe4z2OrjgVu3CNyXRORmWvEV5xv5GMrfakX7SCPBIfBJS5GoyZrsjZ5BEZ/P xlQ8hU4rU4dlT3epZcXW9ZevL6hd2WrLp8cr2ne3ZBEU8BIKR8nPs8mTOvpKPoVUNNaZ a+u3X+QScdAd3kJK4zCwm/Nt/HcxbnKN2RaHskswrdeZ/TCCH6lu0LZODIP6k01idNNu R8QiHE2HCTtbuHcwWMVVvAwNEBONWCgZzXLU8nSzExI7BbVx4AZhOsBu//4arBXMN5Ze IjVthfPvgOgznot55/RN6uPUYFb08RqDqWUUzUmbLZZvlAovjqgGQYFsqTBjyzzH0ksg 8rkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kkHYgEmV; 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 g8si1156930pgr.309.2017.09.19.03.26.09; Tue, 19 Sep 2017 03:26:09 -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=kkHYgEmV; 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 S1751466AbdISK0G (ORCPT + 26 others); Tue, 19 Sep 2017 06:26:06 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:50703 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750974AbdISK0D (ORCPT ); Tue, 19 Sep 2017 06:26:03 -0400 Received: by mail-wm0-f49.google.com with SMTP id v142so3805166wmv.5 for ; Tue, 19 Sep 2017 03:26:02 -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=kkHYgEmVJKj1m9aqQbAiTIrprSgww1J5HvRC8u6ky9gkiJx8Q1xPYa1mfQsC5r/9AK JUHXTAeGr1Nlh97FbghqkUhuFhsLcFQZM09CtZRH1aGXM5SBa0FjIOAlzsaQn3sT7348 0pqi80PSb9cmT86zLEFPk9wshPw4tPfkETn+4= 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=Us/Obag6je5e4+c1W1gv/sW7Sl9qov9VgLh4buyIJNT7iojnysanzG19soYEcynhMw 7Gz4q5OoCIu+JSnwjNGgFU5VZD+6gHTwTM50Lcjh+avag1UEE0f131IRJGILxf8Euf2o tJ3Qso4J5md9rq2QusojYgLbNHSbJaw65446vXzl2kiD+bezQRw1hDgU7+18HsJp5JRJ NH+tR6C57YgAiezEJxttqXKFJVXmdhjvcYDQ4YtAugIKp/FsU20L9DiozYZLLjr76aGb EwcTUDbIDz3/sXymGwPi9HAq2yRkT67BvUeE96BnBVoh0iu5B8j9GhvwT0VqeMTkjBwG /5+w== X-Gm-Message-State: AHPjjUjiF+gEGiMPHDljl1hhTk4qO3hkf2qECr/hwPrCJhldR23o1m0Q Cs4icqXWxjohvXsJIr8SYUcPFQ== X-Google-Smtp-Source: AOwi7QBvbqmhXj5yyyGfNBs7vNRPCgphF1ooDrvqUw6ye5WRSdYwYZrtSmzkQwiQLVif5zP/8udiZQ== X-Received: by 10.28.97.135 with SMTP id v129mr670591wmb.98.1505816761767; Tue, 19 Sep 2017 03:26:01 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.227.50]) by smtp.gmail.com with ESMTPSA id 56sm9039451wrx.2.2017.09.19.03.25.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Sep 2017 03:26:01 -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, Benjamin Gaignard Subject: [PATCH v2 1/2] staging: ion: simplify ioctl args checking function Date: Tue, 19 Sep 2017 12:25:37 +0200 Message-Id: <1505816738-30017-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505816738-30017-1-git-send-email-benjamin.gaignard@linaro.org> References: <1505816738-30017-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 */