lib/string_helpers: add allocated strarray to device resource.
Subsystems (2)
PATCH 1/1 lib/string_helpers: add allocated strarray to device resource.
This is a must to automatically release strarray when the device disappears.
--- lib/string_helpers.c | 1 + 1 file changed, 1 insertion(+)
lib/string_helpers.c +1 -0
@@ -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);
Signature · 1 line
2.17.1
Re: [PATCH] lib/string_helpers: add allocated strarray to device
Hello:
I think this should be added, am I got wrong?
PATCH 1/1 lib/string_helpers: add allocated strarray to device's resource list.
This is a must to automatically release strarray when the device disappears.
--- lib/string_helpers.c | 3 +++ 1 file changed, 3 insertions(+)
lib/string_helpers.c +3 -0
@@ -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);
Signature · 1 line
2.17.1
Re: [PATCH] lib/string_helpers: add allocated strarray to device's resource list.
Quoted 3 lines · Puyou Lu
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.
Quoted 10 lines
Signed-off-by Puyou Lu <[email protected]>--- lib/string_helpers.c | 3 +++ 1 file changed, 3 insertions(+)lib/string_helpers.c +0
-0
lib/string_helpers.c char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n) · line 761
Quoted 5 lines
lib/string_helpers.c +2
-0@@ -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!
Quoted 6 lines
lib/string_helpers.c +0
-1return ptr->array; }EXPORT_SYMBOL_GPL (devm_kasprintf_strarray); --2.17.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 4 lines · Puyou Lu
This is a must to automatically release strarray when the device disappears.
Signed-off-by Puyou Lu <[email protected]>
Looks correct to me.
(But really Tejun is the one who knows how devres is supposed to be used, added on To: line)
Yours,
Linus Walleij