2020-10-27 21:11:37

by Hoegeun Kwon

[permalink] [raw]
Subject: [PATCH 1/1] drm/vc4: drv: Add error handding for bind

There is a problem that if vc4_drm bind fails, a memory leak occurs on
the drm_property_create side. Add error handding for drm_mode_config.

Signed-off-by: Hoegeun Kwon <[email protected]>
---
drivers/gpu/drm/vc4/vc4_drv.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index f1a5fd5dab6f..a17aa1db11b6 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -314,6 +314,7 @@ static int vc4_drm_bind(struct device *dev)
component_unbind_all(dev, drm);
gem_destroy:
vc4_gem_destroy(drm);
+ drm_mode_config_cleanup(drm);
vc4_bo_cache_destroy(drm);
dev_put:
drm_dev_put(drm);
--
2.17.1


2020-10-28 16:53:20

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH 1/1] drm/vc4: drv: Add error handding for bind

Hi,

On Tue, Oct 27, 2020 at 01:14:42PM +0900, Hoegeun Kwon wrote:
> There is a problem that if vc4_drm bind fails, a memory leak occurs on
> the drm_property_create side. Add error handding for drm_mode_config.
>
> Signed-off-by: Hoegeun Kwon <[email protected]>

Applied, thanks!
Maxime


Attachments:
(No filename) (307.00 B)
signature.asc (235.00 B)
Download all attachments

2020-10-28 22:31:36

by Daniel Vetter

[permalink] [raw]
Subject: Re: [PATCH 1/1] drm/vc4: drv: Add error handding for bind

On Tue, Oct 27, 2020 at 03:54:31PM +0100, Maxime Ripard wrote:
> Hi,
>
> On Tue, Oct 27, 2020 at 01:14:42PM +0900, Hoegeun Kwon wrote:
> > There is a problem that if vc4_drm bind fails, a memory leak occurs on
> > the drm_property_create side. Add error handding for drm_mode_config.
> >
> > Signed-off-by: Hoegeun Kwon <[email protected]>
>
> Applied, thanks!

Switching over to drmm_ version of this would also be good I think.
Together with the devm_ version for allocating the drm_device you could
delete a pile of that fragile cleanup code.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch