2023-04-10 18:09:54

by Gencen Gan

[permalink] [raw]
Subject: [PATCH] drm/pl111: fix drm and dev leak when irq request failed.

From: Gan Gecen <[email protected]>

Smatch reports:
pl111_amba_probe() warn: missing unwind goto?

Code segment for dev_put is:
dev_put:
drm_dev_put(drm);
of_reserved_mem_device_release(dev);

When err happened, jumping to dev_put will release
drm and dev resources allocated or initialized
before. But after devm_request_irq() failed, it
returns directly without releasing drm and dev,
which may cause memory leak.

Fixes: 3f9d6bccff6c ("drm/pl111: fix drm and dev leak when irq request failed")
Signed-off-by: Gan Gecen <[email protected]>
---
drivers/gpu/drm/pl111/pl111_drv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c
index 00deba0b7271..52945f7e0aef 100644
--- a/drivers/gpu/drm/pl111/pl111_drv.c
+++ b/drivers/gpu/drm/pl111/pl111_drv.c
@@ -297,7 +297,7 @@ static int pl111_amba_probe(struct amba_device *amba_dev,
variant->name, priv);
if (ret != 0) {
dev_err(dev, "%s failed irq %d\n", __func__, ret);
- return ret;
+ goto dev_put;
}

ret = pl111_modeset_init(drm);
--
2.34.1