Skip to content

Commit 19260d3

Browse files
Jethro Donaldsongregkh
Jethro Donaldson
authored andcommitted
smb: client: fix memory leak during error handling for POSIX mkdir
commit 1fe4a44 upstream. The response buffer for the CREATE request handled by smb311_posix_mkdir() is leaked on the error path (goto err_free_rsp_buf) because the structure pointer *rsp passed to free_rsp_buf() is not assigned until *after* the error condition is checked. As *rsp is initialised to NULL, free_rsp_buf() becomes a no-op and the leak is instead reported by __kmem_cache_shutdown() upon subsequent rmmod of cifs.ko if (and only if) the error path has been hit. Pass rsp_iov.iov_base to free_rsp_buf() instead, similar to the code in other functions in smb2pdu.c for which *rsp is assigned late. Cc: [email protected] Signed-off-by: Jethro Donaldson <[email protected]> Signed-off-by: Steve French <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e604dfc commit 19260d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/smb/client/smb2pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2967,7 +2967,7 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
29672967
/* Eventually save off posix specific response info and timestamps */
29682968

29692969
err_free_rsp_buf:
2970-
free_rsp_buf(resp_buftype, rsp);
2970+
free_rsp_buf(resp_buftype, rsp_iov.iov_base);
29712971
kfree(pc_buf);
29722972
err_free_req:
29732973
cifs_small_buf_release(req);

0 commit comments

Comments
 (0)