Skip to contentSkip to conversation

: add put_device() after of_find_device_by_node()

PATCH In review jing yangyang 2 participants 3 messages Aug 20, 2021 – Aug 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : add put_device() after of_find_device_by_node()

This was found by coccicheck:
./drivers/gpu/drm/kmb/kmb_drv.c:503:2-8:
ERROR missing put_device; call of_find_device_by_node on line 490, but without a corresponding object release within this function.

---
 drivers/gpu/drm/kmb/kmb_drv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/kmb/kmb_drv.c +5 -2
index f54392e..58495a9 100644
@@ -500,8 +500,10 @@ static int kmb_probe(struct platform_device *pdev)
 	ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev));
 
 	if (ret == -EPROBE_DEFER) {
+		put_device(&dsi_pdev->dev);
 		return -EPROBE_DEFER;
 	} else if (ret) {
+		put_device(&dsi_pdev->dev);
 		DRM_ERROR("probe failed to initialize DSI host bridge\n");
 		return ret;
 	}
@@ -509,9 +511,10 @@ static int kmb_probe(struct platform_device *pdev)
 	/* Create DRM device */
 	kmb = devm_drm_dev_alloc(dev, &kmb_driver,
 				 struct kmb_drm_private, drm);
-	if (IS_ERR(kmb))
+	if (IS_ERR(kmb)) {
+		put_device(&dsi_pdev->dev);
 		return PTR_ERR(kmb);
-
+	}
 	dev_set_drvdata(dev, &kmb->drm);
 
 	/* Initialize MIPI DSI */
Signature · 1 line
1.8.3.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 53 lines

-----Original Message-----
From: jing yangyang <[email protected]>
Sent: Thursday, August 19, 2021 7:10 PM
To: Chrisanthus, Anitha <[email protected]>
Cc: Dea, Edmund J <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; [email protected]; linux- [email protected]; jing yangyang <[email protected]>; Zeal Robot <[email protected]>
Subject: [PATCH linux-next] : add put_device() after of_find_device_by_node()

This was found by coccicheck:
./drivers/gpu/drm/kmb/kmb_drv.c:503:2-8:
ERROR missing put_device; call of_find_device_by_node on line 490, but without a corresponding object release within this function.

---
 drivers/gpu/drm/kmb/kmb_drv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/kmb/kmb_drv.c +5 -3
index f54392e..58495a9 100644
@@ -500,8 +500,10 @@ static int kmb_probe(struct platform_device *pdev)
 	ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev));
 
 	if (ret == -EPROBE_DEFER) {
+		put_device(&dsi_pdev->dev);
 		return -EPROBE_DEFER;
 	} else if (ret) {
+		put_device(&dsi_pdev->dev);
 		DRM_ERROR("probe failed to initialize DSI host bridge\n");
 		return ret;
 	}
@@ -509,9 +511,10 @@ static int kmb_probe(struct platform_device *pdev)
 	/* Create DRM device */
 	kmb = devm_drm_dev_alloc(dev, &kmb_driver,
 				 struct kmb_drm_private, drm);
-	if (IS_ERR(kmb))
+	if (IS_ERR(kmb)) {
+		put_device(&dsi_pdev->dev);
 		return PTR_ERR(kmb);
-
+	}
 	dev_set_drvdata(dev, &kmb->drm);
 
 	/* Initialize MIPI DSI */
--

1.8.3.1

#2 lore raw

Hi Jing,

Quoted 11 lines

-----Original Message-----
From: Chrisanthus, Anitha
Sent: Monday, August 23, 2021 4:25 PM
To: jing yangyang <[email protected]>
Cc: Dea, Edmund J <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; [email protected]; linux- [email protected]; jing yangyang <[email protected]>; Zeal Robot <[email protected]>
Subject: RE: [PATCH linux-next] : add put_device() after of_find_device_by_node()

Thanks for the patch. Please add drm/kmb: to the subject line and also correct the checkpatch warning. With that ab.

Quoted 57 lines
Quoted 5 lines

-----Original Message-----
From: jing yangyang <[email protected]>
Sent: Thursday, August 19, 2021 7:10 PM
To: Chrisanthus, Anitha <[email protected]>
Cc: Dea, Edmund J <[email protected]>; David Airlie

<[email protected]>;

Quoted 4 lines

Daniel Vetter <[email protected]>; [email protected]; linux- [email protected]; jing yangyang <[email protected]>; Zeal Robot <[email protected]>
Subject: [PATCH linux-next] : add put_device() after

of_find_device_by_node()

Quoted 44 lines

This was found by coccicheck:
./drivers/gpu/drm/kmb/kmb_drv.c:503:2-8:
ERROR missing put_device; call of_find_device_by_node on line 490, but without a corresponding object release within this function.

---
 drivers/gpu/drm/kmb/kmb_drv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/kmb/kmb_drv.c +5 -3
index f54392e..58495a9 100644
@@ -500,8 +500,10 @@ static int kmb_probe(struct platform_device *pdev)
 	ret = kmb_dsi_host_bridge_init(get_device(&dsi_pdev->dev));
 
 	if (ret == -EPROBE_DEFER) {
+		put_device(&dsi_pdev->dev);
 		return -EPROBE_DEFER;
 	} else if (ret) {
+		put_device(&dsi_pdev->dev);
 		DRM_ERROR("probe failed to initialize DSI host bridge\n");
 		return ret;
 	}
@@ -509,9 +511,10 @@ static int kmb_probe(struct platform_device *pdev)
 	/* Create DRM device */
 	kmb = devm_drm_dev_alloc(dev, &kmb_driver,
 				 struct kmb_drm_private, drm);
-	if (IS_ERR(kmb))
+	if (IS_ERR(kmb)) {
+		put_device(&dsi_pdev->dev);
 		return PTR_ERR(kmb);
-
+	}
 	dev_set_drvdata(dev, &kmb->drm);
 
 	/* Initialize MIPI DSI */
--

1.8.3.1