Skip to content

Commit 25c94b0

Browse files
Yang Yingliangliuw
authored andcommitted
Drivers: hv: vmbus: fix possible memory leak in vmbus_device_register()
If device_register() returns error in vmbus_device_register(), the name allocated by dev_set_name() must be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(). Fixes: 09d50ff ("Staging: hv: make the Hyper-V virtual bus code build") Signed-off-by: Yang Yingliang <[email protected]> Reviewed-by: Michael Kelley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent f92a4b5 commit 25c94b0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,6 +2082,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)
20822082
ret = device_register(&child_device_obj->device);
20832083
if (ret) {
20842084
pr_err("Unable to register child device\n");
2085+
put_device(&child_device_obj->device);
20852086
return ret;
20862087
}
20872088

0 commit comments

Comments
 (0)