Skip to content

Commit a103b83

Browse files
raagjadavandy-shev
authored andcommitted
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 <[email protected]> Signed-off-by: Raag Jadav <[email protected]> Reviewed-by: Dmitry Torokhov <[email protected]> Reviewed-by: Linus Walleij <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent 99e297c commit a103b83

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

include/linux/device/devres.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ void devm_kfree(struct device *dev, const void *p);
7979

8080
void * __realloc_size(3)
8181
devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
82+
static inline void *devm_kmemdup_array(struct device *dev, const void *src,
83+
size_t n, size_t size, gfp_t flags)
84+
{
85+
return devm_kmemdup(dev, src, size_mul(size, n), flags);
86+
}
8287

8388
char * __malloc
8489
devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);

0 commit comments

Comments
 (0)