Skip to contentSkip to conversation

rpmsg: char: release allocated memory

PATCH In review Navid Emamdoost 2 participants 4 messages Sep 17, 2019 – Nov 21, 2019 Remote processor messaging (rpmsg)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpmsg: char: release allocated memory

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

---
 drivers/rpmsg/rpmsg_char.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rpmsg/rpmsg_char.c +4 -2
index eea5ebbb5119..c655074c07c2 100644
@@ -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;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Navid Emamdoost

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

Would you please review this patch?

Thank you,

Quoted 24 lines
---
 drivers/rpmsg/rpmsg_char.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rpmsg/rpmsg_char.c +4 -3
index eea5ebbb5119..c655074c07c2 100644
@@ -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;
--

2.17.1

Signature · 1 line
Navid.
#2 lore raw
Quoted 10 lines · Navid Emamdoost
Quoted 5 lines · Navid Emamdoost

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

Would you please review this patch?

I'm sorry, I must have missed to reply as I applied the patch. You can find it in the rpmsg-next branch [1] and it will be part of the pull request for v5.5

[1] https://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc.git/log/?h=rpmsg-next

Regards,
Bjorn

Quoted 30 lines

Thank you,

Quoted 24 lines
---
 drivers/rpmsg/rpmsg_char.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rpmsg/rpmsg_char.c +4 -3
index eea5ebbb5119..c655074c07c2 100644
@@ -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;
--

2.17.1

Signature · 1 line
Navid.
#3 lore raw

Thanks for the update.

Quoted 53 lines · Bjorn Andersson
Quoted 10 lines · Navid Emamdoost
Quoted 5 lines · Navid Emamdoost

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

Would you please review this patch?

I'm sorry, I must have missed to reply as I applied the patch. You can find it in the rpmsg-next branch [1] and it will be part of the pull request for v5.5

[1] https://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc.git/log/?h=rpmsg-next

Regards,
Bjorn

Quoted 30 lines

Thank you,

Quoted 22 lines
---
 drivers/rpmsg/rpmsg_char.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rpmsg/rpmsg_char.c +4 -3
index eea5ebbb5119..c655074c07c2 100644
@@ -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;
--
Quoted 2 lines

2.17.1

--
Navid.

Signature · 1 line
Navid.