Skip to content

Commit 9914013

Browse files
dakrdliviu
authored andcommitted
drm/arm/hdlcd: use drmm_* to allocate driver structures
Use drm managed resources to allocate driver structures and get rid of the deprecated drm_dev_alloc() call and replace it with devm_drm_dev_alloc(). This also serves as preparation to get rid of drm_device->dev_private and to fix use-after-free issues on driver unload. Signed-off-by: Danilo Krummrich <[email protected]> Signed-off-by: Liviu Dudau <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4b71e26 commit 9914013

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

drivers/gpu/drm/arm/hdlcd_drv.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,11 @@ static int hdlcd_drm_bind(struct device *dev)
247247
struct hdlcd_drm_private *hdlcd;
248248
int ret;
249249

250-
hdlcd = devm_kzalloc(dev, sizeof(*hdlcd), GFP_KERNEL);
251-
if (!hdlcd)
252-
return -ENOMEM;
250+
hdlcd = devm_drm_dev_alloc(dev, &hdlcd_driver, typeof(*hdlcd), base);
251+
if (IS_ERR(hdlcd))
252+
return PTR_ERR(hdlcd);
253253

254-
drm = drm_dev_alloc(&hdlcd_driver, dev);
255-
if (IS_ERR(drm))
256-
return PTR_ERR(drm);
254+
drm = &hdlcd->base;
257255

258256
drm->dev_private = hdlcd;
259257
dev_set_drvdata(dev, drm);
@@ -319,7 +317,6 @@ static int hdlcd_drm_bind(struct device *dev)
319317
err_free:
320318
drm_mode_config_cleanup(drm);
321319
dev_set_drvdata(dev, NULL);
322-
drm_dev_put(drm);
323320

324321
return ret;
325322
}
@@ -344,7 +341,6 @@ static void hdlcd_drm_unbind(struct device *dev)
344341
drm_mode_config_cleanup(drm);
345342
drm->dev_private = NULL;
346343
dev_set_drvdata(dev, NULL);
347-
drm_dev_put(drm);
348344
}
349345

350346
static const struct component_master_ops hdlcd_master_ops = {

drivers/gpu/drm/arm/hdlcd_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __HDLCD_DRV_H__
88

99
struct hdlcd_drm_private {
10+
struct drm_device base;
1011
void __iomem *mmio;
1112
struct clk *clk;
1213
struct drm_crtc crtc;

0 commit comments

Comments
 (0)