diff mbox series

cifs: Fix leak when handling lease break for cached root fid

Message ID 20200626200248.431426-1-paul@darkrain42.org
State New
Headers show
Series cifs: Fix leak when handling lease break for cached root fid | expand

Commit Message

Paul Aurich June 26, 2020, 8:02 p.m. UTC
As observed with kmemleak:

    unreferenced object 0xffff98383a5af480 (size 128):
      comm "cifsd", pid 684, jiffies 4294936606 (age 534.868s)
      hex dump (first 32 bytes):
        c0 ff ff ff 1f 00 00 00 88 f4 5a 3a 38 98 ff ff  ..........Z:8...
        88 f4 5a 3a 38 98 ff ff 80 88 d6 8a ff ff ff ff  ..Z:8...........
        [<0000000068957336>] smb2_is_valid_oplock_break+0x1fa/0x8c0
        [<0000000073b70b9e>] cifs_demultiplex_thread+0x73d/0xcc0
        [<00000000905fa372>] kthread+0x11c/0x150
        [<0000000079378e4e>] ret_from_fork+0x22/0x30

Fixes: a93864d93977 ("cifs: add lease tracking to the cached root fid")
Signed-off-by: Paul Aurich <paul@darkrain42.org>
CC: Stable <stable@vger.kernel.org> # v4.18+
 fs/cifs/smb2misc.c | 1 +
 1 file changed, 1 insertion(+)


Aurélien Aptel June 29, 2020, 9:59 a.m. UTC | #1

Good catch! Change looks good to me but I think we should move lw
allocation inside smb2_tcon_has_lease() so that we don't have to track
it across multiple functions as it is only used there. Could you send a
v2 doing that?

diff mbox series


diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 6a39451973f8..17684b25eb21 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -619,6 +619,7 @@  smb2_is_valid_lease_break(char *buffer)
+					kfree(lw);
 					return true;