summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorNavid Emamdoost <navid.emamdoost@gmail.com>2019-09-11 10:09:02 -0500
committerDavid S. Miller <davem@davemloft.net>2019-09-12 11:58:44 +0100
commita21b7f0cff1906a93a0130b74713b15a0b36481d (patch)
tree4a1f5603ba981ff7d39988495841a8a2b1be91be /net
parent10cc514f451a0f239aa34f91bc9dc954a9397840 (diff)
downloadlinux-a21b7f0cff1906a93a0130b74713b15a0b36481d.tar.bz2
net: qrtr: fix memort leak in qrtr_tun_write_iter
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/qrtr/tun.c5
1 files changed, 4 insertions, 1 deletions
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;
}