On 11/19/25 11:54 PM, Kees Cook wrote:
> Replace open-coded allocate/copy with kvrealloc().
> 
> Signed-off-by: Kees Cook <[email protected]>
> ---
> Cc: Petr Pavlu <[email protected]>
> Cc: Luis Chamberlain <[email protected]>
> Cc: Sami Tolvanen <[email protected]>
> Cc: Daniel Gomez <[email protected]>
> Cc: <[email protected]>
> ---
>  kernel/module/decompress.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel/module/decompress.c b/kernel/module/decompress.c
> index 474e68f0f063..36f52a232a12 100644
> --- a/kernel/module/decompress.c
> +++ b/kernel/module/decompress.c
> @@ -17,16 +17,16 @@
>  static int module_extend_max_pages(struct load_info *info, unsigned int 
> extent)
>  {
>       struct page **new_pages;
> +     unsigned int new_max = info->max_pages + extent;
>  
> -     new_pages = kvmalloc_array(info->max_pages + extent,
> -                                sizeof(info->pages), GFP_KERNEL);
> +     new_pages = kvrealloc(info->pages,
> +                           size_mul(new_max, sizeof(*info->pages)),
> +                           GFP_KERNEL);

Nit: Using the array_size() alias of size_mul() might be clearer in this
context.

It looks ok to me in any case.

Reviewed-by: Petr Pavlu <[email protected]>

-- 
Thanks,
Petr

Reply via email to