]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: fix memory leak of pneg_inbuf on -EOPNOTSUPP ioctl case
authorColin Ian King <colin.king@canonical.com>
Fri, 17 May 2019 08:12:33 +0000 (09:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Jun 2019 07:16:16 +0000 (09:16 +0200)
commit 210782038b54ec8e9059a3c12d6f6ae173efa3a9 upstream.

Currently in the case where SMB2_ioctl returns the -EOPNOTSUPP error
there is a memory leak of pneg_inbuf. Fix this by returning via
the out_free_inbuf exit path that will perform the relevant kfree.

Addresses-Coverity: ("Resource leak")
Fixes: 969ae8e8d4ee ("cifs: Accept validate negotiate if server return NT_STATUS_NOT_SUPPORTED")
CC: Stable <stable@vger.kernel.org> # v5.1+
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/smb2pdu.c

index a37774a55f3aa1b8598ebd30b063fff67d4cb32f..d2d8708f5e1a3c6868f936a2cd71064265ed9947 100644 (file)
@@ -1013,7 +1013,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
                 * not supported error. Client should accept it.
                 */
                cifs_dbg(VFS, "Server does not support validate negotiate\n");
-               return 0;
+               rc = 0;
+               goto out_free_inbuf;
        } else if (rc != 0) {
                cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
                rc = -EIO;