1
0
Fork 0

vfio/mdev: Fix reference count leak in add_mdev_supported_type

[ Upstream commit aa8ba13cae ]

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Thus,
replace kfree() by kobject_put() to fix this issue. Previous
commit "b8eb718348b8" fixed a similar problem.

Fixes: 7b96953bc6 ("vfio: Mediated device Core driver")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
5.4-rM2-2.2.x-imx-squashed
Qiushi Wu 2020-05-27 21:01:09 -05:00 committed by Greg Kroah-Hartman
parent 1957ac8d1b
commit f4fbb592d9
1 changed files with 1 additions and 1 deletions

View File

@ -110,7 +110,7 @@ static struct mdev_type *add_mdev_supported_type(struct mdev_parent *parent,
"%s-%s", dev_driver_string(parent->dev),
group->name);
if (ret) {
kfree(type);
kobject_put(&type->kobj);
return ERR_PTR(ret);
}