lkml.org 
[lkml]   [2013]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/4] pinctrl/abx500: destroy mutex if returning early due to error
On 01/30/2013 12:40 PM, Linus Walleij wrote:
> From: Lee Jones <lee.jones@linaro.org>
>
> Current failure path neglects to mutex_destroy() before returning
> an error due to an invalid parameter or an error received from
> gpiochip_add(). This patch aims to remedy that behaviour.

> diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c

> @@ -1155,11 +1155,13 @@ static int abx500_gpio_probe(struct platform_device *pdev)
> default:
> dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n",
> (int) platid->driver_data);
> + mutex_destroy(&pct->lock);
> return -EINVAL;

Especially given there's already a label out_free which performs this
mutex_destroy(), those last two lines would be better as:

ret = -EINVAL;
goto out_free;

> }
>
> if (!pct->soc) {
> dev_err(&pdev->dev, "Invalid SOC data\n");
> + mutex_destroy(&pct->lock);
> return -EINVAL;

Same there.

> }
>
> @@ -1176,6 +1178,7 @@ static int abx500_gpio_probe(struct platform_device *pdev)
> ret = gpiochip_add(&pct->chip);
> if (ret) {
> dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret);
> + mutex_destroy(&pct->lock);
> goto out_rem_irq;

And here, just change the goto target to out_free rather than adding the
mutex_destroy() call.



\
 
 \ /
  Last update: 2013-01-30 22:01    [W:0.232 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site