]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NFS: sysfs: fix leak when nfs_client kobject add fails
authorYang Xiuwei <yangxiuwei@kylinos.cn>
Thu, 30 Oct 2025 03:03:25 +0000 (11:03 +0800)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 10 Nov 2025 19:30:45 +0000 (14:30 -0500)
If adding the second kobject fails, drop both references to avoid sysfs
residue and memory leak.

Fixes: e96f9268eea6 ("NFS: Make all of /sys/fs/nfs network-namespace unique")
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Reviewed-by: Benjamin Coddington <ben.coddington@hammerspace.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/sysfs.c

index 545148d42dcc98af994162e2245231750fa62a70..ea6e6168092b2920d0eb641f5431fe4c12d3302f 100644 (file)
@@ -189,6 +189,7 @@ static struct nfs_netns_client *nfs_netns_client_alloc(struct kobject *parent,
                        return p;
 
                kobject_put(&p->kobject);
+               kobject_put(&p->nfs_net_kobj);
        }
        return NULL;
 }