Skip to contentSkip to conversation

media: ipu3-cio2: Drop reference on error path in cio2_bridge_connect_sensor()

PATCH Superseded Andy Shevchenko 3 participants 8 messages Jul 26, 2021 – Aug 16, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: ipu3-cio2: Drop reference on error path in cio2_bridge_connect_sensor()

The commit 71f642833284 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()") moved adev assignment outside of error path and hence made acpi_dev_put(sensor->adev) a no-op. We still need to drop reference count on error path, and to achieve that, replace sensor->adev by locally assigned adev.

Fixes 71f642833284 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()")

Depends-on: fc68f42aa737 ("ACPI: fix NULL pointer dereference")

---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
index 59a36f922675..30d29b96a339 100644
@@ -226,7 +226,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 err_free_swnodes:
 	software_node_unregister_nodes(sensor->swnodes);
 err_put_adev:
-	acpi_dev_put(sensor->adev);
+	acpi_dev_put(adev);
 	return ret;
 }
 
Signature · 1 line
2.30.2
maintainer
#1 lore raw

Hi Andy,

Quoted 19 lines · Andy Shevchenko

The commit 71f642833284 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()") moved adev assignment outside of error path and hence made acpi_dev_put(sensor->adev) a no-op. We still need to drop reference count on error path, and to achieve that, replace sensor->adev by locally assigned adev.

Fixes 71f642833284 ("ACPI: utils: Fix reference counting in for_each_acpi_dev_match()")

Depends-on: fc68f42aa737 ("ACPI: fix NULL pointer dereference")

---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
index 59a36f922675..30d29b96a339 100644

drivers/media/pci/intel/ipu3/cio2-bridge.c static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, · line 229

Quoted 5 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
@@ -226,7 +226,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 err_free_swnodes:
 	software_node_unregister_nodes(sensor->swnodes);
 err_put_adev:
-	acpi_dev_put(sensor->adev);
+	acpi_dev_put(adev);

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Quoted 3 lines
drivers/media/pci/intel/ipu3/cio2-bridge.c +0 -0
 	return ret;
 }
 
Signature · 3 lines
Regards,

Sakari Ailus
#2 lore raw
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 8 lines

drivers/media/pci/intel/ipu3/cio2-bridge.c static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, · line 229

Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Are we reading the same version? Or am I missing something?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 12 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 6 lines
Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);
Quoted 4 lines
Quoted 2 lines

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Are we reading the same version? Or am I missing something?

I'm looking at the one in media-tree master.

Signature · 1 line
Sakari Ailus
#4 lore raw
Quoted 13 lines · Sakari Ailus
Quoted 12 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 6 lines
Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Are we reading the same version? Or am I missing something?

I'm looking at the one in media-tree master.

Maintainers with a push access may FF merge the v5.14-rc3 as far as I can tell and then you will see the difference.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#5 lore raw
In reply to Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 6 lines
Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);
Quoted 4 lines
Quoted 2 lines

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Are we reading the same version? Or am I missing something?

Ah. I noticed the adev assignment was removed (and added later) by the other patch. Yeah, agreed; this one's needed.

Signature · 1 line
Sakari Ailus
#6 lore raw
Quoted 13 lines · Sakari Ailus
Quoted 12 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 6 lines
Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Are we reading the same version? Or am I missing something?

Ah. I noticed the adev assignment was removed (and added later) by the other patch. Yeah, agreed; this one's needed.

Thanks! Can we have your tag?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Acked-by
#7 lore raw
Quoted 17 lines · Andy Shevchenko
Quoted 16 lines · Sakari Ailus
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Sakari Ailus

On Mon, Jul 26, 2021 at 11:40:55AM +0300, Andy Shevchenko wrote:

...

Quoted 8 lines

drivers/media/pci/intel/ipu3/cio2-bridge.c static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg, · line 229

Quoted 5 lines

err_free_swnodes:

      software_node_unregister_nodes(sensor->swnodes);

err_put_adev:

drivers/media/pci/intel/ipu3/cio2-bridge.c +1 -1
-     acpi_dev_put(sensor->adev);
+     acpi_dev_put(adev);

adev is assigned to sensor->adev before goto so the two have the same value. I have no problem with the patch though.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Are we reading the same version? Or am I missing something?

Ah. I noticed the adev assignment was removed (and added later) by the other patch. Yeah, agreed; this one's needed.

Thanks! Can we have your tag?

Apologies for the delay.

Signature · 1 line
Sakari Ailus