提交 754e3c0c 编写于 作者: N Navid Emamdoost 提交者: Greg Kroah-Hartman

net: qrtr: fix memort leak in qrtr_tun_write_iter

commit a21b7f0cff1906a93a0130b74713b15a0b36481d upstream.

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: NNavid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 5119ffd4
...@@ -84,11 +84,14 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from) ...@@ -84,11 +84,14 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (!kbuf) if (!kbuf)
return -ENOMEM; return -ENOMEM;
if (!copy_from_iter_full(kbuf, len, from)) if (!copy_from_iter_full(kbuf, len, from)) {
kfree(kbuf);
return -EFAULT; return -EFAULT;
}
ret = qrtr_endpoint_post(&tun->ep, kbuf, len); ret = qrtr_endpoint_post(&tun->ep, kbuf, len);
kfree(kbuf);
return ret < 0 ? ret : len; return ret < 0 ? ret : len;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册