Skip to content

Commit

Permalink
net: qrtr: fix memort leak in qrtr_tun_write_iter
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Navid Emamdoost authored and David S. Miller committed Sep 12, 2019
1 parent 10cc514 commit a21b7f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/qrtr/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a21b7f0

Please sign in to comment.