Skip to content

Commit c15e7c6

Browse files
groecksmfrench
authored andcommitted
smb/server: Fix another refcount leak in smb2_open()
If ksmbd_override_fsids() fails, we jump to err_out2. At that point, fp is NULL because it hasn't been assigned dh_info.fp yet, so ksmbd_fd_put(work, fp) will not be called. However, dh_info.fp was already inserted into the session file table by ksmbd_reopen_durable_fd(), so it will leak in the session file table until the session is closed. Move fp = dh_info.fp; ahead of the ksmbd_override_fsids() check to fix the problem. Found by an experimental AI code review agent at Google. Fixes: c8efcc7 ("ksmbd: add support for durable handles v1/v2") Signed-off-by: Guenter Roeck <[email protected]> Reviewed-by: ChenXiaoSong <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 1f318b9 commit c15e7c6

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/smb/server/smb2pdu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3012,13 +3012,14 @@ int smb2_open(struct ksmbd_work *work)
30123012
goto err_out2;
30133013
}
30143014

3015+
fp = dh_info.fp;
3016+
30153017
if (ksmbd_override_fsids(work)) {
30163018
rc = -ENOMEM;
30173019
ksmbd_put_durable_fd(dh_info.fp);
30183020
goto err_out2;
30193021
}
30203022

3021-
fp = dh_info.fp;
30223023
file_info = FILE_OPENED;
30233024

30243025
rc = ksmbd_vfs_getattr(&fp->filp->f_path, &stat);

0 commit comments

Comments
 (0)