Skip to content

Commit

Permalink
NFS: Don't cleanup sysfs superblock entry if uninitialized
Browse files Browse the repository at this point in the history
Its possible to end up in nfs_free_server() before the server's superblock
sysfs entry has been initialized, in which case calling kobject_put() will
emit a WARNING.  Check if the kobject has been initialized before cleaning
it up.

Fixes: 1c72511 ("NFS: add superblock sysfs entries")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Benjamin Coddington authored and Trond Myklebust committed Jun 29, 2023
1 parent cded49b commit e901f17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/nfs/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,10 @@ void nfs_free_server(struct nfs_server *server)

nfs_put_client(server->nfs_client);

nfs_sysfs_remove_server(server);
kobject_put(&server->kobj);
if (server->kobj.state_initialized) {
nfs_sysfs_remove_server(server);
kobject_put(&server->kobj);
}
ida_free(&s_sysfs_ids, server->s_sysfs_id);

ida_destroy(&server->lockowner_id);
Expand Down

0 comments on commit e901f17

Please sign in to comment.