From patchwork Wed Feb 28 15:27:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 129999 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp1665364edc; Wed, 28 Feb 2018 07:27:57 -0800 (PST) X-Google-Smtp-Source: AH8x225G6+cqIc5cVJWLcNPpqtFly4tSdW5vSFvNKwlqFwFCy+j6+eZI6w18GJNHZAiYwuWATwe2 X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr18382565pla.85.1519831677355; Wed, 28 Feb 2018 07:27:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519831677; cv=none; d=google.com; s=arc-20160816; b=SW3GYytLTCNaPJIVYT/5QY85nhmXyP1rcETzZktx5+rJQyli2LRY8GaYaNbYMEzkGM REJSwtlGQtuzOokBoUckyGGcbMNYwJKuKatWmUeDRHK6KGfa5+w8TOt8rlhkEjSd5gI2 TfOQ41+/7uuYd9FkWErvm3foABXnesJqxoNivPm9tnCefKKS2jv/NJ9JuOlzYt1fZ5qN buNgu0E5qCPuPin5y2DDqFP0bE5ExSOlEedP8aR7BnuEWDersPlNSKxWZ0q4CEgx+TR1 hu3Fjn9bDrthr6LZoh3JqfJ+afKvUZ06kHR7KSsLWHw+2nLjG8lSNRRmHjcZrOYEpp3l /fjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to :arc-authentication-results; bh=9Jrtc1UzFyPCebONntw+S0qfKY0jalgUJ94pQTofry0=; b=YJmOk8CaW8+Uq2j0EfO3npg374U6XP71uCrWE5nKf5jxHBxpC5U8ahiVcICtQZThuf r9ovxgsp047GhXSBtsSJUPwvNxi/Lo0fo6rMksa1vE5ClkiCV6G0xnjXtU/K5ahblTRy R7ozHmRJMXOCepQyQkmHYrIhDHnCjcn29T+h8n2YEchlhEbrvz78GpYlbYT//HypYzOQ jaXga51hce83Fk9wf4Rd47DLNxNyNTCdGBOInZkkuhf4vsLonR0JF81SqXtMoXor39eK WfCne+JnZwSn78cz7T5VOjC+fCwn62pzZ733XC3MMNQSlkXlMzfnMt84A7r6ywDhBlZK rBHg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id q11si1164137pgv.138.2018.02.28.07.27.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2018 07:27:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E68589CF4; Wed, 28 Feb 2018 15:27:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id D85DB89CF4 for ; Wed, 28 Feb 2018 15:27:53 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.15]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id w1SFRfSW026594; Wed, 28 Feb 2018 15:27:41 GMT From: Liviu Dudau To: DRI-devel Subject: [PATCH] drm/drm_ioctl.c: Test client capability value early when setting. Date: Wed, 28 Feb 2018 15:27:41 +0000 Message-Id: <20180228152741.22507-1-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.16.2 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Daniel Vetter , LKML , Liviu Dudau MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The drm_setclientcap() function implementing the DRM_IOCTL_SET_CLIENT_CAP ioctl expects that any capability set by the client will have a value of 1. Make the check early so that we don't have to test the value for each capability. Signed-off-by: Liviu Dudau --- drivers/gpu/drm/drm_ioctl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index af782911c505..02ffa0e8d77b 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -306,22 +306,19 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_set_client_cap *req = data; + if (req->value > 1) + return -EINVAL; + switch (req->capability) { case DRM_CLIENT_CAP_STEREO_3D: - if (req->value > 1) - return -EINVAL; file_priv->stereo_allowed = req->value; break; case DRM_CLIENT_CAP_UNIVERSAL_PLANES: - if (req->value > 1) - return -EINVAL; file_priv->universal_planes = req->value; break; case DRM_CLIENT_CAP_ATOMIC: if (!drm_core_check_feature(dev, DRIVER_ATOMIC)) return -EINVAL; - if (req->value > 1) - return -EINVAL; file_priv->atomic = req->value; file_priv->universal_planes = req->value; break;