[PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call

Andy Shevchenko posted 2 patches 3 weeks, 4 days ago
There is a newer version of this series
[PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
Posted by Andy Shevchenko 3 weeks, 4 days ago
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
Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
Posted by Mary Strodl 3 weeks, 4 days ago
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!
Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
Posted by Andy Shevchenko 3 weeks, 4 days ago
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
Re: [PATCH v1 1/2] gpio: mpsse: Check for error code from devm_mutex_init() call
Posted by Mary Strodl 3 weeks, 4 days ago
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!