From patchwork Mon Oct 29 17:35:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilija Hadzic X-Patchwork-Id: 1664941 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 2D7DBDFB7A for ; Mon, 29 Oct 2012 17:38:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1BE799FD73 for ; Mon, 29 Oct 2012 10:38:29 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by gabe.freedesktop.org (Postfix) with ESMTP id BFD209F777 for ; Mon, 29 Oct 2012 10:36:27 -0700 (PDT) Received: by mail-qa0-f42.google.com with SMTP id t11so1578405qaa.15 for ; Mon, 29 Oct 2012 10:36:27 -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:x-mailer; bh=sLWxb+PFbejbOpXvy5hJa71V7PGKqbleWudb83pQc/4=; b=s6kETNGfakkSGjTDEBr5MogvTZJuHubn444GOzqmqFDZ25bvUHlPdpTSNZgCrsVqSD TPLoJaKkTAPwVv61sAK5X5hogrSPRjJEcZjT5e1RyzF5xomY8n8xJ5vTUSFvDhRdr0wu vEqZAmQeFtRMjlTDk5GmLAK1efNsRWB75vy4tPtIZjgm930sErPHDn7D4keIuKXN0kGk tV+yqf6v5zMh1wyBymjxU0HJy1Zc9IZjRdbAx6QI7TWi67W2S9VNyxnTVruAqhTg/iXo P2mAtJSwivcObsTb3+Ua5ivU7tvRN07xyVwIfSod+vnGwTbb2c2Zmqk8a/KhzcL2VOWc xr8Q== Received: by 10.49.13.202 with SMTP id j10mr6827193qec.27.1351532187017; Mon, 29 Oct 2012 10:36:27 -0700 (PDT) Received: from localhost.localdomain (pool-71-255-86-113.nwrknj.east.verizon.net. [71.255.86.113]) by mx.google.com with ESMTPS id hw8sm6302864qab.9.2012.10.29.10.36.25 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Oct 2012 10:36:26 -0700 (PDT) From: Ilija Hadzic To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: restore open_count if drm_setup fails Date: Mon, 29 Oct 2012 13:35:00 -0400 Message-Id: <1351532101-8523-1-git-send-email-ihadzic@research.bell-labs.com> X-Mailer: git-send-email 1.7.12.4 Cc: stable@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 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 If drm_setup (called at first open) fails, the whole open call has failed, so we should not keep the open_count incremented. Signed-off-by: Ilija Hadzic Cc: stable@vger.kernel.org Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/drm_fops.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 7ef1b67..af68eca 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -135,8 +135,11 @@ int drm_open(struct inode *inode, struct file *filp) retcode = drm_open_helper(inode, filp, dev); if (!retcode) { atomic_inc(&dev->counts[_DRM_STAT_OPENS]); - if (!dev->open_count++) + if (!dev->open_count++) { retcode = drm_setup(dev); + if (retcode) + dev->open_count--; + } } if (!retcode) { mutex_lock(&dev->struct_mutex);