Skip to content

Commit a21b7f0

Browse files
Navidemdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10cc514 commit a21b7f0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/qrtr/tun.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from)
8484
if (!kbuf)
8585
return -ENOMEM;
8686

87-
if (!copy_from_iter_full(kbuf, len, from))
87+
if (!copy_from_iter_full(kbuf, len, from)) {
88+
kfree(kbuf);
8889
return -EFAULT;
90+
}
8991

9092
ret = qrtr_endpoint_post(&tun->ep, kbuf, len);
9193

94+
kfree(kbuf);
9295
return ret < 0 ? ret : len;
9396
}
9497

0 commit comments

Comments
 (0)