Skip to contentSkip to conversation

media: coda: Fix missing put_device() call in coda_get_vdoa_data

PATCH Superseded Miaoqian Lin 2 participants 3 messages Jan 7, 2022 – Jan 12, 2022 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: coda: Fix missing put_device() call in coda_get_vdoa_data

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes e7f3c5481035 ("[media] coda: use VDOA for un-tiling custom macroblock format")
---
 drivers/media/platform/coda/coda-common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/coda/coda-common.c +5 -1
index 0e312b0842d7..579849082488 100644
@@ -405,9 +405,13 @@ static struct vdoa_data *coda_get_vdoa_data(void)
 		goto out;
 
 	vdoa_data = platform_get_drvdata(vdoa_pdev);
-	if (!vdoa_data)
+	if (!vdoa_data) {
 		vdoa_data = ERR_PTR(-EPROBE_DEFER);
+		goto put;
+	}
 
+put:
+	put_device(&vdoa_pdev->dev);
 out:
 	of_node_put(vdoa_node);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Miaoqian Lin

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes e7f3c5481035 ("[media] coda: use VDOA for un-tiling custom macroblock format")
---
 drivers/media/platform/coda/coda-common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/coda/coda-common.c +0 -0
index 0e312b0842d7..579849082488 100644

drivers/media/platform/coda/coda-common.c static struct vdoa_data *coda_get_vdoa_data(void) · line 410

Quoted 7 lines
drivers/media/platform/coda/coda-common.c +2 -1
@@ -405,9 +405,13 @@ static struct vdoa_data *coda_get_vdoa_data(void)
 		goto out;
 
 	vdoa_data = platform_get_drvdata(vdoa_pdev);
-	if (!vdoa_data)
+	if (!vdoa_data) {
 		vdoa_data = ERR_PTR(-EPROBE_DEFER);
+		goto put;

Why the goto put? Just drop the goto...

drivers/media/platform/coda/coda-common.c static struct vdoa_data *coda_get_vdoa_data(void) · line 413

Quoted 3 lines
drivers/media/platform/coda/coda-common.c +2 -0
+	}
 
+put:

...and this label.

drivers/media/platform/coda/coda-common.c static struct vdoa_data *coda_get_vdoa_data(void) · line 414

Quoted 1 line
drivers/media/platform/coda/coda-common.c +1 -0
+	put_device(&vdoa_pdev->dev);

This is the real fix :-)

Regards,

Hans

Quoted 3 lines
drivers/media/platform/coda/coda-common.c +0 -0
 out:
 	of_node_put(vdoa_node);
 
#2 lore raw

PATCH v2 1/1 media: coda: Fix missing put_device() call in coda_get_vdoa_data

The reference taken by 'of_find_device_by_node()' must be released when not needed anymore.
Add the corresponding 'put_device()' in the error handling path.

Fixes e7f3c5481035 ("[media] coda: use VDOA for un-tiling custom macroblock format")

---
Changes in v2:
- remove the goto and unused label.

---
 drivers/media/platform/coda/coda-common.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/coda/coda-common.c +1 -0
index 0e312b0842d7..c3942b0abb00 100644
@@ -408,6 +408,7 @@ static struct vdoa_data *coda_get_vdoa_data(void)
 	if (!vdoa_data)
 		vdoa_data = ERR_PTR(-EPROBE_DEFER);
 
+	put_device(&vdoa_pdev->dev);
 out:
 	of_node_put(vdoa_node);
 
Signature · 1 line
2.17.1