linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr
@ 2019-09-27 23:04 Navid Emamdoost
  2019-09-28  9:54 ` Hans de Goede
  0 siblings, 1 reply; 7+ messages in thread
From: Navid Emamdoost @ 2019-09-27 23:04 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Hans de Goede,
	Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

In hgcm_call_preprocess_linaddr memory is allocated for bounce_buf but
is not released if copy_form_user fails. The release is added.

Fixes: 579db9d45cb4 ("virt: Add vboxguest VMMDEV communication code")

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 drivers/virt/vboxguest/vboxguest_utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/virt/vboxguest/vboxguest_utils.c b/drivers/virt/vboxguest/vboxguest_utils.c
index 75fd140b02ff..7965885a50fa 100644
--- a/drivers/virt/vboxguest/vboxguest_utils.c
+++ b/drivers/virt/vboxguest/vboxguest_utils.c
@@ -222,8 +222,10 @@ static int hgcm_call_preprocess_linaddr(
 
 	if (copy_in) {
 		ret = copy_from_user(bounce_buf, (void __user *)buf, len);
-		if (ret)
+		if (ret) {
+			kvfree(bounce_buf);
 			return -EFAULT;
+		}
 	} else {
 		memset(bounce_buf, 0, len);
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-01  6:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-27 23:04 [PATCH] virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr Navid Emamdoost
2019-09-28  9:54 ` Hans de Goede
2019-09-30  2:22   ` Navid Emamdoost
2019-09-30  8:22     ` Hans de Goede
2019-09-30 20:42       ` [PATCH v2] " Navid Emamdoost
2019-10-01  6:15         ` Hans de Goede
2019-09-30 20:43       ` [PATCH] " Navid Emamdoost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).