Skip to content

Commit b32c8db

Browse files
charsyamsmfrench
authored andcommitted
ksmbd: destroy async_ida in ksmbd_conn_free()
When per-connection async_ida was converted from a dynamically allocated ksmbd_ida to an embedded struct ida, ksmbd_ida_free() was removed from the connection teardown path but no matching ida_destroy() was added. The connection is therefore freed with the IDA's backing xarray still intact. The kernel IDA API expects ida_init() and ida_destroy() to be paired over an object's lifetime, so add the missing cleanup before the connection is freed. No leak has been observed in testing; this is a pairing fix to match the IDA lifetime rules, not a response to a reproduced regression. Fixes: d40012a ("cifsd: declare ida statically") Signed-off-by: DaeMyung Kang <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent c049ee1 commit b32c8db

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

fs/smb/server/connection.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ void ksmbd_conn_free(struct ksmbd_conn *conn)
9898
kfree(conn->preauth_info);
9999
kfree(conn->mechToken);
100100
if (atomic_dec_and_test(&conn->refcnt)) {
101+
/*
102+
* async_ida is embedded in struct ksmbd_conn, so pair
103+
* ida_destroy() with the final kfree() rather than with
104+
* the unconditional field teardown above. This keeps
105+
* the IDA valid for the entire lifetime of the struct,
106+
* even while other refcount holders (oplock / vfs
107+
* durable handles) still reference the connection.
108+
*/
109+
ida_destroy(&conn->async_ida);
101110
conn->transport->ops->free_transport(conn->transport);
102111
kfree(conn);
103112
}

0 commit comments

Comments
 (0)