[v2] net: qrtr: fix memort leak in qrtr_tun_write_iter
diff mbox series

Message ID 20190911150907.18251-1-navid.emamdoost@gmail.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [v2] net: qrtr: fix memort leak in qrtr_tun_write_iter
Related show

Commit Message

Navid Emamdoost Sept. 11, 2019, 3:09 p.m. UTC
In qrtr_tun_write_iter the allocated kbuf should be release in case of
error or success return.

v2 Update: Thanks to David Miller for pointing out the release on success
path as well.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 net/qrtr/tun.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

David Miller Sept. 12, 2019, 10:59 a.m. UTC | #1
From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Wed, 11 Sep 2019 10:09:02 -0500

> In qrtr_tun_write_iter the allocated kbuf should be release in case of
> error or success return.
> 
> v2 Update: Thanks to David Miller for pointing out the release on success
> path as well.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Applied, thanks.

Patch
diff mbox series

diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c
index ccff1e544c21..e35869e81766 100644
--- a/net/qrtr/tun.c
+++ b/net/qrtr/tun.c
@@ -84,11 +84,14 @@  static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)
 	if (!kbuf)
 		return -ENOMEM;
 
-	if (!copy_from_iter_full(kbuf, len, from))
+	if (!copy_from_iter_full(kbuf, len, from)) {
+		kfree(kbuf);
 		return -EFAULT;
+	}
 
 	ret = qrtr_endpoint_post(&tun->ep, kbuf, len);
 
+	kfree(kbuf);
 	return ret < 0 ? ret : len;
 }