All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/string_helpers: add allocated strarray to device resource.
@ 2022-05-06  2:28 Puyou Lu
  2022-05-06  3:23 ` [PATCH] lib/string_helpers: add allocated strarray to device Puyou Lu
  2022-05-12 20:49 ` [PATCH] lib/string_helpers: add allocated strarray to device resource Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Puyou Lu @ 2022-05-06  2:28 UTC (permalink / raw)
  Cc: puyou.lu, Andy Shevchenko, Andrew Morton, Kees Cook, Petr Mladek,
	Linus Walleij, Guenter Roeck, Chris Down, linux-kernel

This is a must to automatically release strarray when the device
disappears.

Signed-off-by: Puyou Lu <puyou.lu@gmail.com>
---
 lib/string_helpers.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 4f877e9551d5..b4497c068172 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -757,6 +757,7 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
 		return ERR_PTR(-ENOMEM);
 	}
 
+	devres_add(dev, ptr);
 	return ptr->array;
 }
 EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);
-- 
2.17.1


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

* Re: [PATCH] lib/string_helpers: add allocated strarray to device
  2022-05-06  2:28 [PATCH] lib/string_helpers: add allocated strarray to device resource Puyou Lu
@ 2022-05-06  3:23 ` Puyou Lu
  2022-05-06  4:44   ` [PATCH] lib/string_helpers: add allocated strarray to device's resource list Puyou Lu
  2022-05-12 20:49 ` [PATCH] lib/string_helpers: add allocated strarray to device resource Linus Walleij
  1 sibling, 1 reply; 5+ messages in thread
From: Puyou Lu @ 2022-05-06  3:23 UTC (permalink / raw)
  To: puyou.lu
  Cc: akpm, andy, chris, keescook, linus.walleij, linux-kernel, linux, pmladek

Hello:
I think this should be added, am I got wrong?

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

* [PATCH] lib/string_helpers: add allocated strarray to device's resource list.
  2022-05-06  3:23 ` [PATCH] lib/string_helpers: add allocated strarray to device Puyou Lu
@ 2022-05-06  4:44   ` Puyou Lu
  2022-05-06  6:43     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Puyou Lu @ 2022-05-06  4:44 UTC (permalink / raw)
  To: puyou.lu
  Cc: akpm, andy, chris, keescook, linus.walleij, linux-kernel, linux, pmladek

This is a must to automatically release strarray when the device
disappears.

Signed-off-by: Puyou Lu <puyou.lu@gmail.com>
---
 lib/string_helpers.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index 4f877e9551d5..5ed3beb066e6 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -757,6 +757,9 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
 		return ERR_PTR(-ENOMEM);
 	}
 
+	ptr->n = n;
+	devres_add(dev, ptr);
+
 	return ptr->array;
 }
 EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);
-- 
2.17.1


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

* Re: [PATCH] lib/string_helpers: add allocated strarray to device's resource list.
  2022-05-06  4:44   ` [PATCH] lib/string_helpers: add allocated strarray to device's resource list Puyou Lu
@ 2022-05-06  6:43     ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-05-06  6:43 UTC (permalink / raw)
  To: Puyou Lu
  Cc: akpm, andy, chris, keescook, linus.walleij, linux-kernel, linux, pmladek

On Fri, May 6, 2022 at 6:44 AM Puyou Lu <puyou.lu@gmail.com> wrote:
>
> This is a must to automatically release strarray when the device
> disappears.

Thanks for your patch!

First of all, since this is a v2 of it, you need to update the subject
to reflect this and add a changelog after the cutter '--- ' line
below.
Second, because this is the fix, please add a Fixes tag.

> Signed-off-by: Puyou Lu <puyou.lu@gmail.com>
> ---
>  lib/string_helpers.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
> index 4f877e9551d5..5ed3beb066e6 100644
> --- a/lib/string_helpers.c
> +++ b/lib/string_helpers.c
> @@ -757,6 +757,9 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
>                 return ERR_PTR(-ENOMEM);
>         }
>
> +       ptr->n = n;
> +       devres_add(dev, ptr);

The code seems correct, good catch!

>         return ptr->array;
>  }
>  EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);
> --
> 2.17.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] lib/string_helpers: add allocated strarray to device resource.
  2022-05-06  2:28 [PATCH] lib/string_helpers: add allocated strarray to device resource Puyou Lu
  2022-05-06  3:23 ` [PATCH] lib/string_helpers: add allocated strarray to device Puyou Lu
@ 2022-05-12 20:49 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2022-05-12 20:49 UTC (permalink / raw)
  To: Puyou Lu, Tejun Heo
  Cc: Andy Shevchenko, Andrew Morton, Kees Cook, Petr Mladek,
	Guenter Roeck, Chris Down, linux-kernel

On Fri, May 6, 2022 at 4:28 AM Puyou Lu <puyou.lu@gmail.com> wrote:

> This is a must to automatically release strarray when the device
> disappears.
>
> Signed-off-by: Puyou Lu <puyou.lu@gmail.com>

Looks correct to me.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

(But really Tejun is the one who knows how devres is supposed
to be used, added on To: line)

Yours,
Linus Walleij

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

end of thread, other threads:[~2022-05-12 20:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-06  2:28 [PATCH] lib/string_helpers: add allocated strarray to device resource Puyou Lu
2022-05-06  3:23 ` [PATCH] lib/string_helpers: add allocated strarray to device Puyou Lu
2022-05-06  4:44   ` [PATCH] lib/string_helpers: add allocated strarray to device's resource list Puyou Lu
2022-05-06  6:43     ` Andy Shevchenko
2022-05-12 20:49 ` [PATCH] lib/string_helpers: add allocated strarray to device resource Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.