Skip to content

Commit

Permalink
rpmsg: char: release allocated memory
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Navidem authored and andersson committed Oct 5, 2019
1 parent 54ecb8f commit bbe692e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/rpmsg/rpmsg_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
if (!kbuf)
return -ENOMEM;

if (!copy_from_iter_full(kbuf, len, from))
return -EFAULT;
if (!copy_from_iter_full(kbuf, len, from)) {
ret = -EFAULT;
goto free_kbuf;
}

if (mutex_lock_interruptible(&eptdev->ept_lock)) {
ret = -ERESTARTSYS;
Expand Down

0 comments on commit bbe692e

Please # to comment.