Message ID | 20171020102033.22936-1-shuwang@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> From: Shu Wang <shuwang@redhat.com> > > Found the issue by kmemleak. The pointer pneg_rsp stores the > pointer kmalloced from SMB2_ioctl, and should be release > before function return. Thanks for the patch, Shu Wang. A fix for this memory leak is already queued at https://bugzilla.samba.org/show_bug.cgi?id=13092 , alongside an extra fix for potential use of uninitialised memory. Patches to follow... Cheers, David -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 6f0e6343c15e..4785ed8e1589 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -727,8 +727,10 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) rsplen); /* relax check since Mac returns max bufsize allowed on ioctl */ - if (rsplen > CIFSMaxBufSize) + if (rsplen > CIFSMaxBufSize) { + kfree(pneg_rsp); return -EIO; + } } /* check validate negotiate info response matches what we got earlier */ @@ -747,10 +749,12 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) /* validate negotiate successful */ cifs_dbg(FYI, "validate negotiate info successful\n"); + kfree(pneg_rsp); return 0; vneg_out: cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n"); + kfree(pneg_rsp); return -EIO; }