]> Git Repo - linux.git/commitdiff
NFS: Fix sysfs server name memory leak
authorBenjamin Coddington <[email protected]>
Mon, 10 Jul 2023 18:41:58 +0000 (14:41 -0400)
committerTrond Myklebust <[email protected]>
Sat, 19 Aug 2023 14:26:29 +0000 (10:26 -0400)
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 <[email protected]>
Signed-off-by: Benjamin Coddington <[email protected]>
Tested-by: Ido Schimmel <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
fs/nfs/sysfs.c

index acda8f033d30d5f02e76749bc0a3522f19bae71e..bf378ecd5d9fdde62ac97587d2b0da505d6cbb83 100644 (file)
@@ -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);
This page took 0.067313 seconds and 4 git commands to generate.