dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Daniel Vetter <daniel.vetter@intel.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	David Airlie <airlied@linux.ie>
Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] drm/i915: add error path
Date: Wed, 22 Jul 2015 16:58:47 +0530	[thread overview]
Message-ID: <1437564527-11667-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)

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 <sudip@vectorindia.org>
---

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)
-- 
1.8.1.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2015-07-22 11:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 11:28 Sudip Mukherjee [this message]
2015-07-22 11:39 ` [Intel-gfx] [PATCH] drm/i915: add error path Chris Wilson
2015-07-22 11:56   ` Sudip Mukherjee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437564527-11667-1-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox