summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaag Jadav <raag.jadav@intel.com>2025-02-12 11:55:05 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-05-29 11:03:15 +0200
commit4a39fbffad5cd3379d517fc034b9cc43771a7854 (patch)
treea8ff5a41db02a552b3c4df66e3c8924093ce523c
parent7207effe4743f49eb8b74ceb66e170b70e4746d2 (diff)
devres: Introduce devm_kmemdup_array()
[ Upstream commit a103b833ac3806b816bc993cba77d0b17cf801f1 ] Introduce '_array' variant of devm_kmemdup() which is more robust and consistent with alloc family of helpers. Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Raag Jadav <raag.jadav@intel.com> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Stable-dep-of: 7dd7f39fce00 ("ASoC: SOF: Intel: hda: Fix UAF when reloading module") Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--include/linux/device/devres.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
index 6b0b265058bc..9b49f9915850 100644
--- a/include/linux/device/devres.h
+++ b/include/linux/device/devres.h
@@ -79,6 +79,11 @@ void devm_kfree(struct device *dev, const void *p);
void * __realloc_size(3)
devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
+static inline void *devm_kmemdup_array(struct device *dev, const void *src,
+ size_t n, size_t size, gfp_t flags)
+{
+ return devm_kmemdup(dev, src, size_mul(size, n), flags);
+}
char * __malloc
devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);