Skip to content

Commit 5a2a6c4

Browse files
bmarzinsMikulas Patocka
authored and
Mikulas Patocka
committed
dm: always update the array size in realloc_argv on success
realloc_argv() was only updating the array size if it was called with old_argv already allocated. The first time it was called to create an argv array, it would allocate the array but return the array size as zero. dm_split_args() would think that it couldn't store any arguments in the array and would call realloc_argv() again, causing it to reallocate the initial slots (this time using GPF_KERNEL) and finally return a size. Aside from being wasteful, this could cause deadlocks on targets that need to process messages without starting new IO. Instead, realloc_argv should always update the allocated array size on success. Fixes: a065192 ("dm table: don't copy from a NULL pointer in realloc_argv()") Cc: [email protected] Signed-off-by: Benjamin Marzinski <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 0a533c3 commit 5a2a6c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/md/dm-table.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,10 @@ static char **realloc_argv(unsigned int *size, char **old_argv)
523523
gfp = GFP_NOIO;
524524
}
525525
argv = kmalloc_array(new_size, sizeof(*argv), gfp);
526-
if (argv && old_argv) {
527-
memcpy(argv, old_argv, *size * sizeof(*argv));
526+
if (argv) {
528527
*size = new_size;
528+
if (old_argv)
529+
memcpy(argv, old_argv, *size * sizeof(*argv));
529530
}
530531

531532
kfree(old_argv);

0 commit comments

Comments
 (0)