linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pinctrl: core: do not explicitly free on unregister
@ 2017-05-16  6:18 Stefan Agner
  2017-05-23  8:20 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Agner @ 2017-05-16  6:18 UTC (permalink / raw)
  To: linus.walleij; +Cc: linux-gpio, linux-kernel, Stefan Agner

When using the resource managed version of pinctrl, resources
might already been freed when pinctrl_unregister is called by the
devres framework. When calling devm_kfree on such a already freed
resource, devres prints a warning:
  WARNING: CPU: 0 PID: 1 at drivers/base/devres.c:891 pinmux_generic_free_functions+0xf4/0x128
  ...

Solve this by not explicitly free resources. The two affected
functions (pinmux_generic_free_functions/pinctrl_generic_free_groups)
are only used in pinctrl_unregister. When not using the resource
managed version of pinctrl, the underlying device will presumably
get freed freed soon anyway.

Signed-off-by: Stefan Agner <stefan@agner.ch>
---
 drivers/pinctrl/core.c   | 1 -
 drivers/pinctrl/pinmux.c | 1 -
 2 files changed, 2 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 1653cbda6a82..bc4c12008cd4 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -702,7 +702,6 @@ static void pinctrl_generic_free_groups(struct pinctrl_dev *pctldev)
 		group = radix_tree_lookup(&pctldev->pin_group_tree,
 					  indices[i]);
 		radix_tree_delete(&pctldev->pin_group_tree, indices[i]);
-		devm_kfree(pctldev->dev, group);
 	}
 
 	pctldev->num_groups = 0;
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 9fd6d9087dc5..87098be84a3c 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -848,7 +848,6 @@ void pinmux_generic_free_functions(struct pinctrl_dev *pctldev)
 		function = radix_tree_lookup(&pctldev->pin_function_tree,
 					     indices[i]);
 		radix_tree_delete(&pctldev->pin_function_tree, indices[i]);
-		devm_kfree(pctldev->dev, function);
 	}
 
 	pctldev->num_functions = 0;
-- 
2.13.0

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

* Re: [PATCH] pinctrl: core: do not explicitly free on unregister
  2017-05-16  6:18 [PATCH] pinctrl: core: do not explicitly free on unregister Stefan Agner
@ 2017-05-23  8:20 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2017-05-23  8:20 UTC (permalink / raw)
  To: Stefan Agner; +Cc: linux-gpio, linux-kernel, ext Tony Lindgren

On Tue, May 16, 2017 at 8:18 AM, Stefan Agner <stefan@agner.ch> wrote:

> When using the resource managed version of pinctrl, resources
> might already been freed when pinctrl_unregister is called by the
> devres framework. When calling devm_kfree on such a already freed
> resource, devres prints a warning:
>   WARNING: CPU: 0 PID: 1 at drivers/base/devres.c:891 pinmux_generic_free_functions+0xf4/0x128
>   ...
>
> Solve this by not explicitly free resources. The two affected
> functions (pinmux_generic_free_functions/pinctrl_generic_free_groups)
> are only used in pinctrl_unregister. When not using the resource
> managed version of pinctrl, the underlying device will presumably
> get freed freed soon anyway.
>
> Signed-off-by: Stefan Agner <stefan@agner.ch>

I think this is no longer needed after the fix from Tony
"pinctrl: core: Fix warning by removing bogus code"

Yours,
Linus Walleij

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

end of thread, other threads:[~2017-05-23  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16  6:18 [PATCH] pinctrl: core: do not explicitly free on unregister Stefan Agner
2017-05-23  8:20 ` Linus Walleij

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).