Skip to content

Commit bf29eda

Browse files
puyoulugregkh
authored andcommitted
lib/string_helpers: fix not adding strarray to device's resource list
commit cd290a9 upstream. Add allocated strarray to device's resource list. This is a must to automatically release strarray when the device disappears. Without this fix we have a memory leak in the few drivers which use devm_kasprintf_strarray(). Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: acdb89b ("lib/string_helpers: Introduce managed variant of kasprintf_strarray()") Signed-off-by: Puyou Lu <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Cc: Tejun Heo <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1815c09 commit bf29eda

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/string_helpers.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
757757
return ERR_PTR(-ENOMEM);
758758
}
759759

760+
ptr->n = n;
761+
devres_add(dev, ptr);
762+
760763
return ptr->array;
761764
}
762765
EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);

0 commit comments

Comments
 (0)