linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/2] gpio: Check for error from devm_mutex_init()
@ 2024-10-30 15:30 Andy Shevchenko
  2024-10-30 15:30 ` [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call Andy Shevchenko
  2024-10-30 15:30 ` [PATCH v1 2/2] gpio: sloppy-logic-analyzer: " Andy Shevchenko
  0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-10-30 15:30 UTC (permalink / raw)
  To: Mary Strodl, Andy Shevchenko, Wolfram Sang, linux-gpio,
	linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Ignoring error checking from devm calls is a bad practice in general.
While not critical today, it may become a problem tomorrow.
Fix this for devm_mutex_init().

Andy Shevchenko (2):
  gpio: mpsse: Check for error code from devm_mutex_init() call
  gpio: sloppy-logic-analyzer: Check for error code from
    devm_mutex_init() call

 drivers/gpio/gpio-mpsse.c                 | 9 +++++++--
 drivers/gpio/gpio-sloppy-logic-analyzer.c | 4 +++-
 2 files changed, 10 insertions(+), 3 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
  2024-10-30 15:30 [PATCH v1 0/2] gpio: Check for error from devm_mutex_init() Andy Shevchenko
@ 2024-10-30 15:30 ` Andy Shevchenko
  2024-10-30 17:12   ` Mary Strodl
  2024-10-30 15:30 ` [PATCH v1 2/2] gpio: sloppy-logic-analyzer: " Andy Shevchenko
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-10-30 15:30 UTC (permalink / raw)
  To: Mary Strodl, Andy Shevchenko, Wolfram Sang, linux-gpio,
	linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Even if it's not critical, the avoidance of checking the error code
from devm_mutex_init() call today diminishes the point of using devm
variant of it. Tomorrow it may even leak something. Add the missed
check.

Fixes: c46a74ff05c0 ("gpio: add support for FTDI's MPSSE as GPIO")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-mpsse.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
index 3ab6651d2226..8fba0779ae17 100644
--- a/drivers/gpio/gpio-mpsse.c
+++ b/drivers/gpio/gpio-mpsse.c
@@ -430,8 +430,13 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
 	if (err)
 		return err;
 
-	devm_mutex_init(dev, &priv->io_mutex);
-	devm_mutex_init(dev, &priv->irq_mutex);
+	err = devm_mutex_init(dev, &priv->io_mutex);
+	if (err)
+		return err;
+
+	ret = devm_mutex_init(dev, &priv->irq_mutex);
+	if (err)
+		return err;
 
 	priv->gpio.label = devm_kasprintf(dev, GFP_KERNEL,
 					  "gpio-mpsse.%d.%d",
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 2/2] gpio: sloppy-logic-analyzer: Check for error code from devm_mutex_init() call
  2024-10-30 15:30 [PATCH v1 0/2] gpio: Check for error from devm_mutex_init() Andy Shevchenko
  2024-10-30 15:30 ` [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call Andy Shevchenko
@ 2024-10-30 15:30 ` Andy Shevchenko
  2024-10-30 16:59   ` Wolfram Sang
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-10-30 15:30 UTC (permalink / raw)
  To: Mary Strodl, Andy Shevchenko, Wolfram Sang, linux-gpio,
	linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Even if it's not critical, the avoidance of checking the error code
from devm_mutex_init() call today diminishes the point of using devm
variant of it. Tomorrow it may even leak something. Add the missed
check.

Fixes: 7828b7bbbf20 ("gpio: add sloppy logic analyzer using polling")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-sloppy-logic-analyzer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-sloppy-logic-analyzer.c b/drivers/gpio/gpio-sloppy-logic-analyzer.c
index 64f2ca4a72b2..8cf3b171c599 100644
--- a/drivers/gpio/gpio-sloppy-logic-analyzer.c
+++ b/drivers/gpio/gpio-sloppy-logic-analyzer.c
@@ -234,7 +234,9 @@ static int gpio_la_poll_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	devm_mutex_init(dev, &priv->blob_lock);
+	ret = devm_mutex_init(dev, &priv->blob_lock);
+	if (ret)
+		return ret;
 
 	fops_buf_size_set(priv, GPIO_LA_DEFAULT_BUF_SIZE);
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* Re: [PATCH v1 2/2] gpio: sloppy-logic-analyzer: Check for error code from devm_mutex_init() call
  2024-10-30 15:30 ` [PATCH v1 2/2] gpio: sloppy-logic-analyzer: " Andy Shevchenko
@ 2024-10-30 16:59   ` Wolfram Sang
  0 siblings, 0 replies; 7+ messages in thread
From: Wolfram Sang @ 2024-10-30 16:59 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mary Strodl, linux-gpio, linux-kernel, Linus Walleij,
	Bartosz Golaszewski

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

On Wed, Oct 30, 2024 at 05:30:27PM +0200, Andy Shevchenko wrote:
> Even if it's not critical, the avoidance of checking the error code
> from devm_mutex_init() call today diminishes the point of using devm
> variant of it. Tomorrow it may even leak something. Add the missed
> check.
> 
> Fixes: 7828b7bbbf20 ("gpio: add sloppy logic analyzer using polling")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
  2024-10-30 15:30 ` [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call Andy Shevchenko
@ 2024-10-30 17:12   ` Mary Strodl
  2024-10-30 17:33     ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Mary Strodl @ 2024-10-30 17:12 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, linux-gpio, linux-kernel, Linus Walleij,
	Bartosz Golaszewski

Hello Andy!

On Wed, Oct 30, 2024 at 05:30:26PM +0200, Andy Shevchenko wrote:
> Even if it's not critical, the avoidance of checking the error code
> from devm_mutex_init() call today diminishes the point of using devm
> variant of it. Tomorrow it may even leak something. Add the missed
> check.
Totally missed this... Thanks!

> @@ -430,8 +430,13 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
>  	if (err)
>  		return err;
>  
> -	devm_mutex_init(dev, &priv->io_mutex);
> -	devm_mutex_init(dev, &priv->irq_mutex);
> +	err = devm_mutex_init(dev, &priv->io_mutex);
> +	if (err)
> +		return err;
> +
> +	ret = devm_mutex_init(dev, &priv->irq_mutex);

I think this should be `err = `

Other than that, it looks good to me (I doubt you need this, but just in case):

Reviewed-by: Mary Strodl <mstrodl@csh.rit.edu>

Thanks!

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

* Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
  2024-10-30 17:12   ` Mary Strodl
@ 2024-10-30 17:33     ` Andy Shevchenko
  2024-10-30 17:38       ` Mary Strodl
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-10-30 17:33 UTC (permalink / raw)
  To: Mary Strodl
  Cc: Wolfram Sang, linux-gpio, linux-kernel, Linus Walleij,
	Bartosz Golaszewski

On Wed, Oct 30, 2024 at 01:12:01PM -0400, Mary Strodl wrote:
> On Wed, Oct 30, 2024 at 05:30:26PM +0200, Andy Shevchenko wrote:

...

> > +	err = devm_mutex_init(dev, &priv->io_mutex);
> > +	if (err)
> > +		return err;
> > +
> > +	ret = devm_mutex_init(dev, &priv->irq_mutex);
> 
> I think this should be `err = `

Oh, I haven't compiled that for sure :-)

> Other than that, it looks good to me (I doubt you need this, but just in case):
> 
> Reviewed-by: Mary Strodl <mstrodl@csh.rit.edu>

Thanks, I will fix that, I dunno how I missed that because I carefully read
the code before adding the checks.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
  2024-10-30 17:33     ` Andy Shevchenko
@ 2024-10-30 17:38       ` Mary Strodl
  0 siblings, 0 replies; 7+ messages in thread
From: Mary Strodl @ 2024-10-30 17:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, linux-gpio, linux-kernel, Linus Walleij,
	Bartosz Golaszewski

On Wed, Oct 30, 2024 at 07:33:17PM +0200, Andy Shevchenko wrote:
> Thanks, I will fix that, I dunno how I missed that because I carefully read
> the code before adding the checks.
Proof that it happens to the best of us :)

Thanks again!

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

end of thread, other threads:[~2024-10-30 17:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 15:30 [PATCH v1 0/2] gpio: Check for error from devm_mutex_init() Andy Shevchenko
2024-10-30 15:30 ` [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call Andy Shevchenko
2024-10-30 17:12   ` Mary Strodl
2024-10-30 17:33     ` Andy Shevchenko
2024-10-30 17:38       ` Mary Strodl
2024-10-30 15:30 ` [PATCH v1 2/2] gpio: sloppy-logic-analyzer: " Andy Shevchenko
2024-10-30 16:59   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).