[PATCH] drm/mipi-dsi: Fix reference count leak in mipi_dsi_device_register_full

Guangshuo Li posted 1 patch 5 days, 19 hours ago
drivers/gpu/drm/drm_mipi_dsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] drm/mipi-dsi: Fix reference count leak in mipi_dsi_device_register_full
Posted by Guangshuo Li 5 days, 19 hours ago
mipi_dsi_device_alloc() initializes the embedded device. If
mipi_dsi_device_add() fails, put_device() should be called to properly
drop the device reference and release the memory associated with the
object.

The current error path directly frees the mipi_dsi_device with kfree(),
bypassing the device release callback.

This issue was found by a static analysis tool I am developing.

Fixes: 068a00233969 ("drm: Add MIPI DSI bus support")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 0390e14d3157..862d56eaf934 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -233,7 +233,7 @@ mipi_dsi_device_register_full(struct mipi_dsi_host *host,
 	ret = mipi_dsi_device_add(dsi);
 	if (ret) {
 		dev_err(host->dev, "failed to add DSI device %d\n", ret);
-		kfree(dsi);
+		put_device(&dsi->dev);
 		return ERR_PTR(ret);
 	}
 
-- 
2.43.0