From patchwork Mon Feb 7 23:18:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 539151 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p17NIQMm013959 for ; Mon, 7 Feb 2011 23:18:48 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D47949E860 for ; Mon, 7 Feb 2011 15:18:25 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga14.intel.com (mga14.intel.com [143.182.124.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 76D039E7C3 for ; Mon, 7 Feb 2011 15:18:16 -0800 (PST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 07 Feb 2011 15:18:16 -0800 Message-Id: <849307$bfi2og@azsmga001.ch.intel.com> X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.60,439,1291622400"; d="scan'208";a="385420048" Received: from unknown (HELO cwilso3-mobl.ger.corp.intel.com) ([10.255.16.176]) by azsmga001.ch.intel.com with SMTP; 07 Feb 2011 15:18:13 -0800 Received: by cwilso3-mobl.ger.corp.intel.com (sSMTP sendmail emulation); Mon, 07 Feb 2011 23:18:12 +0000 Date: Mon, 07 Feb 2011 23:18:12 +0000 To: Dave Airlie , adam zeira Subject: Re: drm_open doesnt lock before increasing dev->open_count References: <1297119172.23505.1.camel@clockmaker-el6> From: Chris Wilson In-Reply-To: <1297119172.23505.1.camel@clockmaker-el6> Cc: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 23:18:48 +0000 (UTC) diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 2ec7d48..5b4ca5b 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -125,6 +125,13 @@ int drm_open(struct inode *inode, struct file *filp) struct drm_minor *minor; int retcode = 0; + /* Typically we are called (via the driver) from drm_stub_open() + * as their own fops->open and so already hold the global mutex. + * Enforce this. + */ + if (WARN_ON(!mutex_is_locked(&drm_global_mutex))) + return -EINVAL; + minor = idr_find(&drm_minors_idr, minor_id); if (!minor) return -ENODEV;