Skip to contentSkip to conversation

io_uring: Fix sizeof() mismatch

PATCH In review Colin King 2 participants 2 messages Oct 12, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 io_uring: Fix sizeof() mismatch

From: Colin Ian King <[email protected]>

An incorrect sizeof() is being used, sizeof(file_data->table) is not correct, it should be sizeof(*file_data->table).

Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)")

Fixes 5398ae698525 ("io_uring: clean file_data access in files_register")
---
 fs/io_uring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/io_uring.c +1 -1
index b58169240c77..6b30670fffbd 100644
@@ -7306,7 +7306,7 @@ static int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg,
 	spin_lock_init(&file_data->lock);
 
 	nr_tables = DIV_ROUND_UP(nr_args, IORING_MAX_FILES_TABLE);
-	file_data->table = kcalloc(nr_tables, sizeof(file_data->table),
+	file_data->table = kcalloc(nr_tables, sizeof(*file_data->table),
 				   GFP_KERNEL);
 	if (!file_data->table)
 		goto out_free;
Signature · 1 line
2.27.0
maintainer
#1 lore raw
Quoted 4 lines · Colin King

From: Colin Ian King <[email protected]>

An incorrect sizeof() is being used, sizeof(file_data->table) is not correct, it should be sizeof(*file_data->table).

Thanks, should be a no-op, which is why KASAN didn't complain in my testing. I'll queue this up, thanks.

Signature · 1 line
Jens Axboe