From patchwork Wed Aug 3 18:04:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 9261701 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0EC1F60754 for ; Wed, 3 Aug 2016 18:05:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0410B281F9 for ; Wed, 3 Aug 2016 18:05:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED45C28249; Wed, 3 Aug 2016 18:05:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A89BB281F9 for ; Wed, 3 Aug 2016 18:05:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4DEF6E899; Wed, 3 Aug 2016 18:05:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0A246E894 for ; Wed, 3 Aug 2016 18:05:06 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id o80so37486809wme.0 for ; Wed, 03 Aug 2016 11:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K3m+BU8y3K1wqOw7P0r4b9bDN6QXUk+3Mw3/HCT25to=; b=LG/yVBmlGlQVfZcyp1/b31qo+ftvuIa+xS95OODmLDXYQtRMRiYM1+mQCYgqHRbAle qLyELWNXuUqQXsxpwRkQz1AOY3QxcZTwzIE420UX5I5YIdH7uruXNSt/zATeQ4Jvn3ry 2j0IJ78BsykHp71lxmZhAHsm7XJ4jcBliBBeduLYH6wxqK+OezRqwYpTtkic35NDYOWV edVHzj7ICkwqQI1qSoZ95RAtGIrf/KuxTyDUiwVrI3yJWWKkbomNUjpQ3TOitf98eQQS wYcawDc0YnY3n93tL8KlJ5qlZjRmM4n1ZjIjZyTxaf/s5iLKq99IX/iclX+vGT0bFx79 Sdng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K3m+BU8y3K1wqOw7P0r4b9bDN6QXUk+3Mw3/HCT25to=; b=fHj4RVBwTNVXxmiVOODhMZLHEm6XQT8zFTt7D/icJIYvzKvVVKe9glRxye06hpAihc NOStEFOVuoUY7LrCPfliGONtHWqyg4FLMWuySF2omde+H3tmy02BxeZB7Gm3xmXtJ8bW l7L86zzAwucoGxcwSVBSjp7KaoVX4ubzp5RIhVEVgAVVXvhwc77/xuagyYCLES+9HbNg vlW0iYNbpA11gzM1p0ekwjIQsKH9bDPyTiQFQ3e58pYqDG+fhgVdSohTZFTikFnopOBs b32mSo9LZp5FZwzSA4F1HB4s1ZIG0CUpb+FqhlPuq+VJ8AdH4FlAXQmDcFXcFhzkW2vV nQng== X-Gm-Message-State: AEkooutw7BIZtDof8a1wcyXwF45Ozde1pbiGwfePUm3jOvqvvI9LKf2wBAw1uSFK1A2/TQ== X-Received: by 10.194.87.101 with SMTP id w5mr68311661wjz.94.1470247504100; Wed, 03 Aug 2016 11:05:04 -0700 (PDT) Received: from localhost.localdomain ([37.120.18.65]) by smtp.gmail.com with ESMTPSA id va3sm8854296wjb.18.2016.08.03.11.05.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Aug 2016 11:05:02 -0700 (PDT) From: David Herrmann To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/8] drm: rename drm_file.filp to drm_file.legacy_filp Date: Wed, 3 Aug 2016 20:04:31 +0200 Message-Id: <20160803180432.1341-8-dh.herrmann@gmail.com> X-Mailer: git-send-email 2.9.2 In-Reply-To: <20160803180432.1341-1-dh.herrmann@gmail.com> References: <20160803180432.1341-1-dh.herrmann@gmail.com> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP We don't want anyone but legacy DRM1 code to use drm_file.filp. Especially for in-kernel contexts, this might be set to NULL, so lets make sure no-one accesses it, ever. Signed-off-by: David Herrmann --- drivers/gpu/drm/drm_bufs.c | 7 ++++--- drivers/gpu/drm/drm_fops.c | 2 +- include/drm/drmP.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c index c3a12cd..d2803de 100644 --- a/drivers/gpu/drm/drm_bufs.c +++ b/drivers/gpu/drm/drm_bufs.c @@ -1456,7 +1456,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data, if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA)) return -EINVAL; - if (!dma) + if (!dma || !file_priv->legacy_filp) return -EINVAL; spin_lock(&dev->buf_lock); @@ -1478,12 +1478,13 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data, retcode = -EINVAL; goto done; } - virtual = vm_mmap(file_priv->filp, 0, map->size, + virtual = vm_mmap(file_priv->legacy_filp, 0, map->size, PROT_READ | PROT_WRITE, MAP_SHARED, token); } else { - virtual = vm_mmap(file_priv->filp, 0, dma->byte_count, + virtual = vm_mmap(file_priv->legacy_filp, 0, + dma->byte_count, PROT_READ | PROT_WRITE, MAP_SHARED, 0); } diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index e9d66f5..69ef23c 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -198,7 +198,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) return -ENOMEM; filp->private_data = priv; - priv->filp = filp; + priv->legacy_filp = filp; priv->pid = get_pid(task_pid(current)); priv->minor = minor; diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 0f69f56..2197ab1 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -330,7 +330,7 @@ struct drm_file { /** Lock for synchronization of access to object_idr. */ spinlock_t table_lock; - struct file *filp; + struct file *legacy_filp; /* might be NULL! */ void *driver_priv; struct drm_master *master; /* master this node is currently associated with