NFS: sysfs: fix leak when nfs_client kobject add fails

[ Upstream commit 7a7a345652 ]

If adding the second kobject fails, drop both references to avoid sysfs
residue and memory leak.

Fixes: e96f9268ee ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Yang Xiuwei
2025-10-30 11:03:25 +08:00
committed by Greg Kroah-Hartman
parent fc022d7d5b
commit b03837f838

View 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;
}