diff options
author | Raag Jadav <raag.jadav@intel.com> | 2025-02-12 11:55:05 +0530 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2025-02-24 12:08:52 +0200 |
commit | a103b833ac3806b816bc993cba77d0b17cf801f1 (patch) | |
tree | d0cad32acfd7b086189b32b4590230417f3c3081 | |
parent | 99e297cdd338b8a18c986ed4e088676579b7fe96 (diff) |
devres: Introduce devm_kmemdup_array()
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>
-rw-r--r-- | include/linux/device/devres.h | 5 |
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); |