2022-05-09 09:02:12

by Puyou Lu

[permalink] [raw]
Subject: [PATCH] lib/string_helpers: add allocated strarray to device resource.

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

Signed-off-by: Puyou Lu <[email protected]>
---
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



2022-05-14 03:52:12

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] lib/string_helpers: add allocated strarray to device resource.

On Fri, May 6, 2022 at 4:28 AM Puyou Lu <[email protected]> wrote:

> This is a must to automatically release strarray when the device
> disappears.
>
> Signed-off-by: Puyou Lu <[email protected]>

Looks correct to me.
Reviewed-by: Linus Walleij <[email protected]>

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

Yours,
Linus Walleij