All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, ebiederm@xmission.com,
	kay@vrfy.org, Tejun Heo <tj@kernel.org>
Subject: [PATCH 4/6] kernfs: update kernfs_rename_ns() to consider KERNFS_STATIC_NAME
Date: Wed, 11 Dec 2013 16:02:58 -0500	[thread overview]
Message-ID: <1386795780-23324-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1386795780-23324-1-git-send-email-tj@kernel.org>

kernfs_rename_ns() currently assumes that the target sysfs_dirent has
a copied name.  This has been okay because sysfs supports rename only
for directories which always have copied names; however, there's
nothing in kernfs interface which calls for such restriction and
currently invoking kernfs_rename_ns() on a regular file leads to oops
because it ends up trying to kfree() a static name.

This patch updates kernfs_rename_ns() so that it skips kfree() of the
old name if it's static.  This allows it to be used for all node
types.

Signed-off-by: Tejun Heo <tj@kernel.org>
---
 fs/kernfs/dir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index e168177..d33af95 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -886,7 +886,11 @@ int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
 		if (!new_name)
 			goto out;
 
-		kfree(kn->name);
+		if (kn->flags & KERNFS_STATIC_NAME)
+			kn->flags &= ~KERNFS_STATIC_NAME;
+		else
+			kfree(kn->name);
+
 		kn->name = new_name;
 	}
 
-- 
1.8.4.2


  parent reply	other threads:[~2013-12-11 21:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 21:02 [PATCHSET driver-core-next] kernfs: implement kernfs_dir_ops Tejun Heo
2013-12-11 21:02 ` [PATCH 1/6] kernfs: add @mode to kernfs_create_dir[_ns]() Tejun Heo
2013-12-11 21:02 ` [PATCH 2/6] kernfs: add REMOVED check to create and rename paths Tejun Heo
2013-12-11 21:02 ` [PATCH 3/6] kernfs: mark static names with KERNFS_STATIC_NAME Tejun Heo
2013-12-11 21:02 ` Tejun Heo [this message]
2013-12-11 21:02 ` [PATCH 5/6] kernfs: allow negative dentries Tejun Heo
2013-12-11 21:03 ` [PATCH 6/6] kernfs: add kernfs_dir_ops Tejun Heo
2013-12-11 21:05 ` test-kernfs module Tejun Heo
2013-12-11 21:19 ` [PATCHSET driver-core-next] kernfs: implement kernfs_dir_ops Greg KH
2013-12-11 21:22   ` Tejun Heo

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=1386795780-23324-5-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kay@vrfy.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.