Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rpmsg: char: release allocated memory

In rpmsg_eptdev_write_iter, if copy_from_iter_full fails the allocated
buffer needs to be released.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Navid Emamdoost and committed by
Bjorn Andersson
bbe692e3 54ecb8f7

+4 -2
+4 -2
drivers/rpmsg/rpmsg_char.c
··· 227 227 if (!kbuf) 228 228 return -ENOMEM; 229 229 230 - if (!copy_from_iter_full(kbuf, len, from)) 231 - return -EFAULT; 230 + if (!copy_from_iter_full(kbuf, len, from)) { 231 + ret = -EFAULT; 232 + goto free_kbuf; 233 + } 232 234 233 235 if (mutex_lock_interruptible(&eptdev->ept_lock)) { 234 236 ret = -ERESTARTSYS;