[PATCH] vfio/mdev: fix missed mdev free in mdev_device_create() error path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add mdev kfree in mdev_device_create() error path which seems
to be ignored.

Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
Cc: Alex Williamson <alex.williamson@xxxxxxxxxx>
Cc: Kirti Wankhede <kwankhede@xxxxxxxxxx>
Signed-off-by: Zhenyu Wang <zhenyuw@xxxxxxxxxxxxxxx>
---
 drivers/vfio/mdev/mdev_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 0212f0ee8aea..40a8f7280639 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -294,7 +294,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
 		if (!uuid_le_cmp(tmp->uuid, uuid)) {
 			mutex_unlock(&mdev_list_lock);
 			ret = -EEXIST;
-			goto mdev_fail;
+			goto parent_put;
 		}
 	}
 
@@ -302,7 +302,7 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
 	if (!mdev) {
 		mutex_unlock(&mdev_list_lock);
 		ret = -ENOMEM;
-		goto mdev_fail;
+		goto parent_put;
 	}
 
 	memcpy(&mdev->uuid, &uuid, sizeof(uuid_le));
@@ -342,6 +342,8 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
 create_fail:
 	device_unregister(&mdev->dev);
 mdev_fail:
+	kfree(mdev);
+parent_put:
 	mdev_put_parent(parent);
 	return ret;
 }
-- 
2.19.0.rc1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux