#include <linux/string.h>
 #include <linux/types.h>
 
+struct device;
 struct file;
 struct task_struct;
 
 char **kasprintf_strarray(gfp_t gfp, const char *prefix, size_t n);
 void kfree_strarray(char **array, size_t n);
 
+char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n);
+
 #endif
 
 #include <linux/math64.h>
 #include <linux/export.h>
 #include <linux/ctype.h>
+#include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/fs.h>
 #include <linux/limits.h>
 }
 EXPORT_SYMBOL_GPL(kfree_strarray);
 
+struct strarray {
+       char **array;
+       size_t n;
+};
+
+static void devm_kfree_strarray(struct device *dev, void *res)
+{
+       struct strarray *array = res;
+
+       kfree_strarray(array->array, array->n);
+}
+
+char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n)
+{
+       struct strarray *ptr;
+
+       ptr = devres_alloc(devm_kfree_strarray, sizeof(*ptr), GFP_KERNEL);
+       if (!ptr)
+               return ERR_PTR(-ENOMEM);
+
+       ptr->array = kasprintf_strarray(GFP_KERNEL, prefix, n);
+       if (!ptr->array) {
+               devres_free(ptr);
+               return ERR_PTR(-ENOMEM);
+       }
+
+       return ptr->array;
+}
+EXPORT_SYMBOL_GPL(devm_kasprintf_strarray);
+
 /**
  * strscpy_pad() - Copy a C-string into a sized buffer
  * @dest: Where to copy the string to