1
0
Fork 0

cifs: fix leaked reference on requeued write

commit a481379960 upstream.

Failed async writes that are requeued may not clean up a refcount
on the file, which can result in a leaked open. This scenario arises
very reliably when using persistent handles and a reconnect occurs
while writing.

cifs_writev_requeue only releases the reference if the write fails
(rc != 0). The server->ops->async_writev operation will take its own
reference, so the initial reference can always be released.

Signed-off-by: Adam McCoy <adam@forsedomani.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
5.4-rM2-2.2.x-imx-squashed
Adam McCoy 2020-05-13 11:53:30 +00:00 committed by Greg Kroah-Hartman
parent 4e06196336
commit f8e370ccab
1 changed files with 1 additions and 1 deletions

View File

@ -2135,8 +2135,8 @@ cifs_writev_requeue(struct cifs_writedata *wdata)
}
}
kref_put(&wdata2->refcount, cifs_writedata_release);
if (rc) {
kref_put(&wdata2->refcount, cifs_writedata_release);
if (is_retryable_error(rc))
continue;
i += nr_pages;