cifs: fix memory leak in SMB2_read
authorRonnie Sahlberg <lsahlber@redhat.com>
Tue, 23 Apr 2019 06:39:45 +0000 (16:39 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 May 2019 17:42:30 +0000 (19:42 +0200)
[ Upstream commit 05fd5c2c61732152a6bddc318aae62d7e436629b ]

Commit 088aaf17aa79300cab14dbee2569c58cfafd7d6e introduced a leak where
if SMB2_read() returned an error we would return without freeing the
request buffer.

Cc: Stable <stable@vger.kernel.org>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
fs/cifs/smb2pdu.c

index fd2d199dd413e1386c0ef573abe3736da2d111b8..7936eac5a38a2eb9fe52b65ea84ecec06e8d10df 100644 (file)
@@ -2699,6 +2699,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
                        cifs_dbg(VFS, "Send error in read = %d\n", rc);
                }
                free_rsp_buf(resp_buftype, rsp_iov.iov_base);
+               cifs_small_buf_release(req);
                return rc == -ENODATA ? 0 : rc;
        }