summaryrefslogtreecommitdiff
path: root/fs/udf
diff options
context:
space:
mode:
authorDenis Efremov <efremov@linux.com>2020-08-28 01:16:52 +0300
committerJan Kara <jack@suse.cz>2020-08-28 12:28:58 +0200
commit256ccb9baeaba2b1a4ed5324c02b8d723497ca5a (patch)
tree52c36150aa7bb165a2a3c12899efa8e4dac27f5b /fs/udf
parent25094ede57d4c5b7ad6474b0b4490f12d21b3702 (diff)
downloadlinux-256ccb9baeaba2b1a4ed5324c02b8d723497ca5a.tar.gz
udf: Use kvzalloc() in udf_sb_alloc_bitmap()
Use kvzalloc() in udf_sb_alloc_bitmap() instead of open-coding it. Size computation wrapped in struct_size() macro to prevent potential integer overflows. Link: https://lore.kernel.org/r/20200827221652.64660-1-efremov@linux.com Signed-off-by: Denis Efremov <efremov@linux.com> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/super.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 1c42f544096d..d9eabbe368ff 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1006,18 +1006,10 @@ int udf_compute_nr_groups(struct super_block *sb, u32 partition)
static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
{
struct udf_bitmap *bitmap;
- int nr_groups;
- 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 */
+ int nr_groups = udf_compute_nr_groups(sb, index);
+ bitmap = kvzalloc(struct_size(bitmap, s_block_bitmap, nr_groups),
+ GFP_KERNEL);
if (!bitmap)
return NULL;