summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam McCoy <adam@forsedomani.com>2020-05-13 14:53:30 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-05-20 09:18:49 +0300
commitad149b6e08f1ee582f1d2ffa747f463e9b6f1c40 (patch)
treea28d17d379d24eb3a801b32170312260ea6e47bf
parent643ca7097dae63661eee1e5fd163dd82e9e1d433 (diff)
downloadlinux-ad149b6e08f1ee582f1d2ffa747f463e9b6f1c40.tar.xz
cifs: fix leaked reference on requeued write
commit a48137996063d22ffba77e077425f49873856ca5 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>
-rw-r--r--fs/cifs/cifssmb.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 8b9471904f67..cb70f0c6aa1b 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2051,8 +2051,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;