pinctrl: pinctrl-pic32: Fix resource leak and convert last manual allocation to devres
Subsystems (2)
v2 cover pinctrl: pinctrl-pic32: Fix resource leak and convert last manual allocation to devres
I made this a series so it's easier to backport the bugfix.
Ethan Tidmore (2):
pinctrl: pinctrl-pic32: Fix resource leak
pinctrl: pinctrl-pic32: Use devres version of gpiochip_add_data()
drivers/pinctrl/pinctrl-pic32.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/2 pinctrl: pinctrl-pic32: Fix resource leak
Fix three possible resource leaks by using the devres version of clk_prepare_enable(). Also, update error message accordingly.
Detected by Smatch:drivers/pinctrl/pinctrl-pic32.c:2211 pic32_pinctrl_probe() warn:
'pctl->clk' from clk_prepare_enable() not released on lines: 2208.
drivers/pinctrl/pinctrl-pic32.c:2274 pic32_gpio_probe() warn:
'bank->clk' from clk_prepare_enable() not released on lines: 2264,2272.
---
v2:
- Use devres instead of manual cleanup.
drivers/pinctrl/pinctrl-pic32.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/pinctrl/pinctrl-pic32.c +4 -16
@@ -2174,16 +2174,10 @@ static int pic32_pinctrl_probe(struct platform_device *pdev)if (IS_ERR (pctl->reg_base))return PTR_ERR (pctl->reg_base); - pctl->clk =devm_clk_get (&pdev->dev,NULL ); + pctl->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (pctl->clk)) { ret =PTR_ERR (pctl->clk); -dev_err (&pdev->dev,"clk get failed\n" ); -return ret; - } - - ret =clk_prepare_enable (pctl->clk); -if (ret) { -dev_err (&pdev->dev,"clk enable failed\n" ); +dev_err (&pdev->dev,"Failed to get and enable clock\n" );return ret; }
@@ -2239,16 +2233,10 @@ static int pic32_gpio_probe(struct platform_device *pdev)if (irq <0 )return irq; - bank->clk =devm_clk_get (&pdev->dev,NULL ); + bank->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (bank->clk)) { ret =PTR_ERR (bank->clk); -dev_err (&pdev->dev,"clk get failed\n" ); -return ret; - } - - ret =clk_prepare_enable (bank->clk); -if (ret) { -dev_err (&pdev->dev,"clk enable failed\n" ); +dev_err (&pdev->dev,"Failed to get and enable clock\n" );return ret; }
Signature · 1 line
2.53.0
PATCH v2 2/2 pinctrl: pinctrl-pic32: Use devres version of gpiochip_add_data()
In reply to Ethan TidmoreConvert gpiochip_add_data() to devm_gpiochip_add_data() to use devres style cleanup across entire driver.
---
v2:
- Made this a series, added this patch.
drivers/pinctrl/pinctrl-pic32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-pic32.c +1 -1
@@ -2253,7 +2253,7 @@ static int pic32_gpio_probe(struct platform_device *pdev) girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_level_irq; girq->parents[0 ] = irq; - ret =gpiochip_add_data (&bank->gpio_chip, bank); + ret =devm_gpiochip_add_data (&pdev->dev, &bank->gpio_chip, bank);if (ret <0 ) {dev_err (&pdev->dev,"Failed to add GPIO chip %u: %d\n" , id, ret);
Signature · 1 line
2.53.0
Linus Walleij
maintainerQuoted 5 lines · Ethan Tidmore
I made this a series so it's easier to backport the bugfix.
Ethan Tidmore (2):
pinctrl: pinctrl-pic32: Fix resource leak
pinctrl: pinctrl-pic32: Use devres version ofgpiochip_add_data()
Patches applied as nonurgent fixes, thanks Ethan!
Yours,
Linus Walleij