virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Mon, 30 Sep 2019 20:42:22 +0000 (15:42 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Nov 2019 12:06:04 +0000 (13:06 +0100)
commitc2ea451f22f180e9e46225f54b5ec50c50bb639f
tree7515f57cdadc1ce73e110d9b1dd963fa3d0078f5
parent5865397db6c3a9eb5c790e5c01ace9b29f3955d1
virt: vbox: fix memory leak in hgcm_call_preprocess_linaddr

[ Upstream commit e0b0cb9388642c104838fac100a4af32745621e2 ]

In hgcm_call_preprocess_linaddr memory is allocated for bounce_buf but
is not released if copy_form_user fails. In order to prevent memory leak
in case of failure, the assignment to bounce_buf_ret is moved before the
error check. This way the allocated bounce_buf will be released by the
caller.

Fixes: 579db9d45cb4 ("virt: Add vboxguest VMMDEV communication code")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20190930204223.3660-1-navid.emamdoost@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/virt/vboxguest/vboxguest_utils.c