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

[PATCH] xen/balloon: drop the device reference if registration fails



register_balloon() registers the statically allocated balloon device.
When device_register() fails, device_add() drops the reference it took
itself but the reference taken by device_initialize() stays behind, so
the device's private data and name are never released.

Give up that reference with put_device() before unregistering the bus.

Fixes: 803eb047a28d ("xen-balloon: Move core balloon functionality out of 
module")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
 drivers/xen/xen-balloon.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/xen/xen-balloon.c b/drivers/xen/xen-balloon.c
index 67b0e2dbe84a..e1db8b2ffc1e 100644
--- a/drivers/xen/xen-balloon.c
+++ b/drivers/xen/xen-balloon.c
@@ -256,6 +256,7 @@ static int register_balloon(struct device *dev)
 
        error = device_register(dev);
        if (error) {
+               put_device(dev);
                bus_unregister(&balloon_subsys);
                return error;
        }
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.