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)
committerSteve French <stfrench@microsoft.com>
Wed, 29 May 2019 00:11:35 +0000 (19:11 -0500)
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>
fs/cifs/smb2pdu.c

index 710ceb875161a5a70e67f9af0e95f5b53b7b5284..5b8d1482ffbd4369490e4afcada6c1fd9b598c5f 100644 (file)
@@ -1054,7 +1054,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;