From: Al Viro <viro@zeniv.linux.org.uk>
To: AnishMulay <anishm7030@gmail.com>
Cc: rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com,
linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tracefs: Simplify get_dname() with kmemdup_nul()
Date: Fri, 27 Feb 2026 20:18:24 +0000 [thread overview]
Message-ID: <20260227201824.GE3836593@ZenIV> (raw)
In-Reply-To: <20260227194453.213095-1-anishm7030@gmail.com>
On Fri, Feb 27, 2026 at 02:44:53PM -0500, AnishMulay wrote:
> index d9d8932a7b9c9..86ba8dc25aaef 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -96,17 +96,7 @@ static struct tracefs_dir_ops {
>
> static char *get_dname(struct dentry *dentry)
> {
> - const char *dname;
> - char *name;
> - int len = dentry->d_name.len;
> -
> - dname = dentry->d_name.name;
> - name = kmalloc(len + 1, GFP_KERNEL);
> - if (!name)
> - return NULL;
> - memcpy(name, dname, len);
> - name[len] = 0;
> - return name;
> + return kmemdup_nul(dentry->d_name.name, dentry->d_name.len, GFP_KERNEL);
> }
Why not have the callers use {take,release}_dentry_name_snapshot()
instead of doing any allocations at all?
I mean,
static struct dentry *tracefs_syscall_mkdir(struct mnt_idmap *idmap,
struct inode *inode, struct dentry *dentry,
umode_t mode)
{
struct tracefs_inode *ti;
struct name_snapshot s;
int ret;
take_dentry_name_snapshot(&s, dentry);
...
ret = tracefs_ops.mkdir(s.name.name);
release_dentry_name_snapshot(&s);
...
}
and similar on the rmdir side. Then remove get_dname()...
next prev parent reply other threads:[~2026-02-27 20:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 19:44 [PATCH] tracefs: Simplify get_dname() with kmemdup_nul() AnishMulay
2026-02-27 20:18 ` Al Viro [this message]
2026-02-27 20:42 ` Steven Rostedt
2026-02-27 21:15 ` [PATCH v2] tracefs: Use dentry name snapshots instead of heap allocation AnishMulay
2026-03-05 18:12 ` Steven Rostedt
2026-03-05 21:52 ` Steven Rostedt
2026-03-06 20:04 ` [PATCH v3] " AnishMulay
2026-03-06 21:41 ` Steven Rostedt
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=20260227201824.GE3836593@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=anishm7030@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.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.