lkml.org 
[lkml]   [2021]   [Aug]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/5] fs/ntfs3: Use kmalloc_array over kmalloc with multiply
From
Date
On Tue, 2021-08-31 at 21:15 +0300, Kari Argillander wrote:
> If we do not use kmalloc_array we get checkpatch warning. It is also
> little safer if something goes wrong with coding.
[]
> diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
[]
> @@ -707,7 +707,7 @@ static struct NTFS_DE *hdr_find_e(const struct ntfs_index *indx,
>   u16 *ptr;
>   int new_slots = ALIGN(2 * nslots, 8);
>  
>
> - ptr = kmalloc(sizeof(u16) * new_slots, GFP_NOFS);
> + ptr = kmalloc_array(new_slots, sizeof(u16), GFP_NOFS);
>   if (ptr)
>   memcpy(ptr, offs, sizeof(u16) * max_idx);

This multiplication could also overflow.

Maybe use krealloc?


\
 
 \ /
  Last update: 2021-09-01 04:41    [W:0.088 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site