drm/mipi-dsi: fix possible memory leak in mipi_dsi_device_register_full()
Subsystems (2)
PATCH 1/1 drm/mipi-dsi: fix possible memory leak in mipi_dsi_device_register_full()
If mipi_dsi_device_add() fails, the refcount of device is not 0, the name allocated in dev_set_name() is leaked. Fix this by calling put_device(), so that it will be freed in callback function kobject_cleanup().
Fixes 068a00233969 ("drm: Add MIPI DSI bus support")
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/gpu/drm/drm_mipi_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_mipi_dsi.c +1 -1
@@ -228,7 +228,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host, ret =mipi_dsi_device_add (dsi);if (ret) {drm_err (host,"failed to add DSI device %d\n" , ret); -kfree (dsi); +put_device (&dsi->dev);return ERR_PTR (ret); }
Signature · 1 line
2.25.1
Quoted 9 lines · Yang Yingliang
If
mipi_dsi_device_add()fails, the refcount of device is not 0, the name allocated indev_set_name()is leaked. Fix this by callingput_device(), so that it will be freed in callback functionkobject_cleanup().Fixes 068a00233969 ("drm: Add MIPI DSI bus support")Signed-off-by Yang Yingliang <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Good catch! The device_initialize() function (which is called via mipi_dsi_device_alloc() earlier in mipi_dsi_device_register_full()) has a comment that put_device() should be used after it was called.
Reviewed-by Thierry Reding <[email protected]>