mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
devres: Provide krealloc_array
There is no krealloc_array equivalent in devres. Users would have to do their own multiplication overflow check so provide one. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: James Clark <james.clark@arm.com> Link: https://lore.kernel.org/r/20230509094942.396150-2-james.clark@arm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7877cb91f1
commit
d388f06ace
@ -364,6 +364,7 @@ MEM
|
||||
devm_kmalloc_array()
|
||||
devm_kmemdup()
|
||||
devm_krealloc()
|
||||
devm_krealloc_array()
|
||||
devm_kstrdup()
|
||||
devm_kstrdup_const()
|
||||
devm_kvasprintf()
|
||||
|
@ -223,6 +223,17 @@ static inline void *devm_kcalloc(struct device *dev,
|
||||
{
|
||||
return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
|
||||
}
|
||||
static inline __realloc_size(3, 4) void * __must_check
|
||||
devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
|
||||
{
|
||||
size_t bytes;
|
||||
|
||||
if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
|
||||
return NULL;
|
||||
|
||||
return devm_krealloc(dev, p, bytes, flags);
|
||||
}
|
||||
|
||||
void devm_kfree(struct device *dev, const void *p);
|
||||
char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
|
||||
const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
|
||||
|
Loading…
Reference in New Issue
Block a user