[PATCH 3/3] vfio/mbochs: Fix the null-ptr-deref bug in mbochs_dev_init()

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

 



if kstrdup() fails in kobject_set_name_varg() in dev_set_name(), the
strchr() in kobject_add() of device_add() will cause null-ptr-deref below.
So check the err of dev_set_name().

Fixes: a5e6e6505f38 ("sample: vfio bochs vbe display (host device for bochs-drm)")
Signed-off-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
---
 samples/vfio-mdev/mbochs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
index 3764d1911b51..b7f8518cd48a 100644
--- a/samples/vfio-mdev/mbochs.c
+++ b/samples/vfio-mdev/mbochs.c
@@ -1430,7 +1430,9 @@ static int __init mbochs_dev_init(void)
 	}
 	mbochs_dev.class = mbochs_class;
 	mbochs_dev.release = mbochs_device_release;
-	dev_set_name(&mbochs_dev, "%s", MBOCHS_NAME);
+	ret = dev_set_name(&mbochs_dev, "%s", MBOCHS_NAME);
+	if (ret)
+		goto err_put;
 
 	ret = device_register(&mbochs_dev);
 	if (ret)
-- 
2.34.1




[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