From patchwork Wed Jul 22 11:28:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6842241 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA6289F38B for ; Wed, 22 Jul 2015 11:29:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F109E2074E for ; Wed, 22 Jul 2015 11:29:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 047D02064B for ; Wed, 22 Jul 2015 11:29:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DC6F26E4D5; Wed, 22 Jul 2015 04:29:03 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 768E06E1CF; Wed, 22 Jul 2015 04:29:02 -0700 (PDT) Received: by pabkd10 with SMTP id kd10so65227491pab.2; Wed, 22 Jul 2015 04:29:02 -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; bh=T0O/POwLPvly6cLpk/VOFg4H/HdBFMK7Po+1tgpJr+0=; b=kDqvyOmPt3M8AXOpUfgFwH52hjt0oXsqg7intS5dh/2a9ceRfwN9xJxGuAJYpaJank DTwnUZ7TrXMxD9rkBICopOuk28vBxQJxjPAMrON9vArnEv7hOYZE2d8vwQYceLxnQihb DcawLaDYPv9b+T68r/3GAqMJ0WPa1ci4XI0FlsrTNwI8JY3opICNKjBEkJMKeTbak4zn RFDPPF+nIHyOBaR0381C7iXToTskg7WA8rGEJI6MvsaRt5V+p6s2ESWuQyiU7INVThRx wLykntYjejoRFEtGernsX23k5QGr++ZFPaZiDnHoBiDu4h1Y7Gd5N+/fz+DH7lPZSzlH WyRw== X-Received: by 10.66.251.202 with SMTP id zm10mr1781502pac.87.1437564542028; Wed, 22 Jul 2015 04:29:02 -0700 (PDT) Received: from localhost.localdomain ([49.206.252.123]) by smtp.gmail.com with ESMTPSA id ml10sm2832743pab.47.2015.07.22.04.28.59 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Jul 2015 04:29:01 -0700 (PDT) From: Sudip Mukherjee To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH] drm/i915: add error path Date: Wed, 22 Jul 2015 16:58:47 +0530 Message-Id: <1437564527-11667-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.8.1.2 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sudip Mukherjee 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-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If any of the debug file creation fails we were just returning the error code to the drm layer. But the debug files that we created in the process were not removed. And debugfs files are not automatically cleaned up. Signed-off-by: Sudip Mukherjee --- Hi Daniel, Whom should i keep Cc: for this patch? Original code was from 2009, then more codes have been added and changed in it. drivers/gpu/drm/i915/i915_debugfs.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index caf1382..24b04f9 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -5147,7 +5147,7 @@ int i915_debugfs_init(struct drm_minor *minor) for (i = 0; i < ARRAY_SIZE(i915_pipe_crc_data); i++) { ret = i915_pipe_crc_create(minor->debugfs_root, minor, i); if (ret) - return ret; + goto err_pipe_crc; } for (i = 0; i < ARRAY_SIZE(i915_debugfs_files); i++) { @@ -5155,12 +5155,34 @@ int i915_debugfs_init(struct drm_minor *minor) i915_debugfs_files[i].name, i915_debugfs_files[i].fops); if (ret) - return ret; + goto err_debugfs; } return drm_debugfs_create_files(i915_debugfs_list, I915_DEBUGFS_ENTRIES, minor->debugfs_root, minor); + +err_debugfs: + while (--i >= 0) { + struct drm_info_list *info_list = + (struct drm_info_list *)i915_debugfs_files[i].fops; + + drm_debugfs_remove_files(info_list, 1, minor); + } + +err_pipe_crc: + if (i == -1) + i = ARRAY_SIZE(i915_pipe_crc_data); + + while (--i >= 0) { + struct drm_info_list *info_list = + (struct drm_info_list *)&i915_pipe_crc_data[i]; + drm_debugfs_remove_files(info_list, 1, minor); + } + drm_debugfs_remove_files((struct drm_info_list *)&i915_forcewake_fops, + 1, minor); + + return ret; } void i915_debugfs_cleanup(struct drm_minor *minor)