lkml.org 
[lkml]   [2022]   [Oct]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4 1/6] devres: provide devm_krealloc_array()
From

On 07/10/2022 18:18, Andy Shevchenko wrote:
>> {
>> return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
>> }
> Missed blank line?

There is no blank line after the definitions of devm_kzalloc(),
devm_kmalloc_array() and devm_kcalloc() defined just above.

>
>> +static inline void *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;
> I'm not sure it is what we want, but I have read the man realloc and found this:
>
> ... reallocarray() fails safely in the case where the multiplication
> would overflow. If such an overflow occurs, reallocarray() returns NULL,
> sets errno to ENOMEM, and leaves the original block of memory
> unchanged.
>
> So, perhaps you can add that this behaviour mimics reallocarray()?

except for the errno part, that is what is does. I don't think we should
use ERR_PTR in this case as the other allocation functions don't use it.

>
>> + return devm_krealloc(dev, p, bytes, flags);
>> +}
> ...
>
> All comments are minor, feel free to add
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>

\
 
 \ /
  Last update: 2022-10-14 11:17    [W:0.280 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site