From: Benjamin Coddington <bcodding@redhat.com>
To: trond.myklebust@hammerspace.com, anna@kernel.org
Cc: aahringo@redhat.com, linux-nfs@vger.kernel.org
Subject: [PATCH] NFS: Fix sysfs server name memory leak
Date: Mon, 10 Jul 2023 14:41:58 -0400 [thread overview]
Message-ID: <6702796fee0365bf399800326bbe6c88e5f73f68.1689014440.git.bcodding@redhat.com> (raw)
Free the formatted server index string after it has been duplicated by
kobject_rename().
Fixes: 1c7251187dc0 ("NFS: add superblock sysfs entries")
Reported-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
---
fs/nfs/sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index acda8f033d30..bf378ecd5d9f 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -345,8 +345,10 @@ void nfs_sysfs_move_sb_to_server(struct nfs_server *server)
int ret = -ENOMEM;
s = kasprintf(GFP_KERNEL, "server-%d", server->s_sysfs_id);
- if (s)
+ if (s) {
ret = kobject_rename(&server->kobj, s);
+ kfree(s);
+ }
if (ret < 0)
pr_warn("NFS: rename sysfs %s failed (%d)\n",
server->kobj.name, ret);
--
2.40.1
next reply other threads:[~2023-07-10 18:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 18:41 Benjamin Coddington [this message]
2023-07-12 12:10 ` [PATCH] NFS: Fix sysfs server name memory leak Ido Schimmel
2023-07-14 15:20 ` Geert Uytterhoeven
2023-08-15 11:59 ` Geert Uytterhoeven
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=6702796fee0365bf399800326bbe6c88e5f73f68.1689014440.git.bcodding@redhat.com \
--to=bcodding@redhat.com \
--cc=aahringo@redhat.com \
--cc=anna@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/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.