All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices
@ 2021-04-04 18:14 Andy Shevchenko
  2021-04-05 20:37 ` Daniel Scally
  2021-04-21 14:03 ` Sakari Ailus
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-04-04 18:14 UTC (permalink / raw)
  To: Andy Shevchenko, Daniel Scally, linux-media, linux-kernel
  Cc: Yong Zhi, Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab

When we continue, due to device is disabled, loop we have to drop reference count.
When we have an array full of devices we have to also drop the reference count.
Note, in this case the cio2_bridge_unregister_sensors() is called by the caller.

Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver")
Cc: Daniel Scally <djrscally@gmail.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index c2199042d3db..85f8b587405e 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -173,14 +173,15 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 	int ret;
 
 	for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
-		if (!adev->status.enabled)
+		if (!adev->status.enabled) {
+			acpi_dev_put(adev);
 			continue;
+		}
 
 		if (bridge->n_sensors >= CIO2_NUM_PORTS) {
+			acpi_dev_put(adev);
 			dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
-			cio2_bridge_unregister_sensors(bridge);
-			ret = -EINVAL;
-			goto err_out;
+			return -EINVAL;
 		}
 
 		sensor = &bridge->sensors[bridge->n_sensors];
@@ -228,7 +229,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 	software_node_unregister_nodes(sensor->swnodes);
 err_put_adev:
 	acpi_dev_put(sensor->adev);
-err_out:
 	return ret;
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices
  2021-04-04 18:14 [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices Andy Shevchenko
@ 2021-04-05 20:37 ` Daniel Scally
  2021-04-13 16:10   ` Andy Shevchenko
  2021-04-21 14:03 ` Sakari Ailus
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Scally @ 2021-04-05 20:37 UTC (permalink / raw)
  To: Andy Shevchenko, linux-media, linux-kernel
  Cc: Yong Zhi, Sakari Ailus, Bingbu Cao, Tianshu Qiu, Mauro Carvalho Chehab

Hi Andy

On 04/04/2021 19:14, Andy Shevchenko wrote:
> When we continue, due to device is disabled, loop we have to drop reference count.
> When we have an array full of devices we have to also drop the reference count.
> Note, in this case the cio2_bridge_unregister_sensors() is called by the caller.
>
> Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver")
> Cc: Daniel Scally <djrscally@gmail.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>


Ah; thanks for catching those, I'm annoyed to have missed the
acpi_dev_put() calls in particular

Reviewed-by: Daniel Scally <djrscally@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices
  2021-04-05 20:37 ` Daniel Scally
@ 2021-04-13 16:10   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-04-13 16:10 UTC (permalink / raw)
  To: Daniel Scally
  Cc: linux-media, linux-kernel, Yong Zhi, Sakari Ailus, Bingbu Cao,
	Tianshu Qiu, Mauro Carvalho Chehab

On Mon, Apr 05, 2021 at 09:37:28PM +0100, Daniel Scally wrote:
> On 04/04/2021 19:14, Andy Shevchenko wrote:
> > When we continue, due to device is disabled, loop we have to drop reference count.
> > When we have an array full of devices we have to also drop the reference count.
> > Note, in this case the cio2_bridge_unregister_sensors() is called by the caller.
> >
> > Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver")
> > Cc: Daniel Scally <djrscally@gmail.com>
> > Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> Ah; thanks for catching those, I'm annoyed to have missed the
> acpi_dev_put() calls in particular
> 
> Reviewed-by: Daniel Scally <djrscally@gmail.com>

Sakari, Mauro, can this be applied as v5.12 material, please?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices
  2021-04-04 18:14 [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices Andy Shevchenko
  2021-04-05 20:37 ` Daniel Scally
@ 2021-04-21 14:03 ` Sakari Ailus
  2021-04-21 15:05   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Sakari Ailus @ 2021-04-21 14:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Daniel Scally, linux-media, linux-kernel, Yong Zhi, Bingbu Cao,
	Tianshu Qiu, Mauro Carvalho Chehab

Hi Andy,

Thanks for the patch.

On Sun, Apr 04, 2021 at 09:14:09PM +0300, Andy Shevchenko wrote:
> When we continue, due to device is disabled, loop we have to drop reference count.
> When we have an array full of devices we have to also drop the reference count.
> Note, in this case the cio2_bridge_unregister_sensors() is called by the caller.

Please limit the commit message to 75 chars, at least if there's no reason
to do otherwise.

I can wrap it this time.

> 
> Fixes: 803abec64ef9 ("media: ipu3-cio2: Add cio2-bridge to ipu3-cio2 driver")
> Cc: Daniel Scally <djrscally@gmail.com>
> Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> ---
>  drivers/media/pci/intel/ipu3/cio2-bridge.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
> index c2199042d3db..85f8b587405e 100644
> --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
> @@ -173,14 +173,15 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>  	int ret;
>  
>  	for_each_acpi_dev_match(adev, cfg->hid, NULL, -1) {
> -		if (!adev->status.enabled)
> +		if (!adev->status.enabled) {
> +			acpi_dev_put(adev);
>  			continue;
> +		}
>  
>  		if (bridge->n_sensors >= CIO2_NUM_PORTS) {
> +			acpi_dev_put(adev);
>  			dev_err(&cio2->dev, "Exceeded available CIO2 ports\n");
> -			cio2_bridge_unregister_sensors(bridge);
> -			ret = -EINVAL;
> -			goto err_out;
> +			return -EINVAL;
>  		}
>  
>  		sensor = &bridge->sensors[bridge->n_sensors];
> @@ -228,7 +229,6 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>  	software_node_unregister_nodes(sensor->swnodes);
>  err_put_adev:
>  	acpi_dev_put(sensor->adev);
> -err_out:
>  	return ret;
>  }
>  

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices
  2021-04-21 14:03 ` Sakari Ailus
@ 2021-04-21 15:05   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-04-21 15:05 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Daniel Scally, Linux Media Mailing List,
	Linux Kernel Mailing List, Yong Zhi, Bingbu Cao, Tianshu Qiu,
	Mauro Carvalho Chehab

On Wed, Apr 21, 2021 at 5:04 PM Sakari Ailus
<sakari.ailus@linux.intel.com> wrote:
> On Sun, Apr 04, 2021 at 09:14:09PM +0300, Andy Shevchenko wrote:
> > When we continue, due to device is disabled, loop we have to drop reference count.
> > When we have an array full of devices we have to also drop the reference count.
> > Note, in this case the cio2_bridge_unregister_sensors() is called by the caller.
>
> Please limit the commit message to 75 chars, at least if there's no reason
> to do otherwise.

OK.

> I can wrap it this time.

Thanks!

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-21 15:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-04 18:14 [PATCH v1 1/1] media: ipu3-cio2: Fix referece counting when looping over ACPI devices Andy Shevchenko
2021-04-05 20:37 ` Daniel Scally
2021-04-13 16:10   ` Andy Shevchenko
2021-04-21 14:03 ` Sakari Ailus
2021-04-21 15:05   ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.