[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0caaeb1e-6f71-b97f-f86c-22819c30e31f@embeddedor.com>
Date: Thu, 27 Aug 2020 17:09:14 -0500
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Denis Efremov <efremov@...ux.com>, Jan Kara <jack@...e.com>
Cc: linux-kernel@...r.kernel.org, Joe Perches <joe@...ches.com>
Subject: Re: [PATCH v2] udf: Use kvzalloc() in udf_sb_alloc_bitmap()
On 8/27/20 16:25, Denis Efremov wrote:
> Use kvzalloc() in udf_sb_alloc_bitmap() instead of open-coding it.
> Size computation wrapped in struct_size() macro to prevent potential
> integer overflows.
>
> Signed-off-by: Denis Efremov <efremov@...ux.com>
> ---
Please, comment here what changed in v2, vn... e.g.:
Changes in v2:
- Use struct_size() helper.
> fs/udf/super.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 1c42f544096d..bdf51bea54f3 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -1010,14 +1010,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
> int size;
>
> nr_groups = udf_compute_nr_groups(sb, index);
> - size = sizeof(struct udf_bitmap) +
> - (sizeof(struct buffer_head *) * nr_groups);
> -
> - if (size <= PAGE_SIZE)
> - bitmap = kzalloc(size, GFP_KERNEL);
> - else
> - bitmap = vzalloc(size); /* TODO: get rid of vzalloc */
> + size = struct_size(bitmap, s_block_bitmap, nr_groups);
>
> + bitmap = kvzalloc(size, GFP_KERNEL);
Why not this:
bitmap = kvzalloc(struct_size(bitmap, s_block_bitmap, nr_groups),
GFP_KERNEL);
and you can also get rid of _size_ entirely.
Thanks
--
Gustavo
> if (!bitmap)
> return NULL;
>
>
Powered by blists - more mailing lists