From 4c79d55678b8bf993cb94c6181180997112bb353 Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Thu, 30 Nov 2023 19:54:56 -0500 Subject: [PATCH] dm vdo: fix how dm_kcopyd_client_create() failure is checked dm_kcopyd_client_create() returns an ERR_PTR so its return must be checked with IS_ERR(). Signed-off-by: Mike Snitzer Signed-off-by: Chung Chung Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo-target.c | 8 ++++++-- drivers/md/dm-vdo/slab-depot.c | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-vdo-target.c b/drivers/md/dm-vdo-target.c index 72d2291dd93f..4fbc148681e5 100644 --- a/drivers/md/dm-vdo-target.c +++ b/drivers/md/dm-vdo-target.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1683,8 +1684,11 @@ static int grow_layout(struct vdo *vdo, block_count_t old_size, block_count_t ne /* Make a copy completion if there isn't one */ if (vdo->partition_copier == NULL) { vdo->partition_copier = dm_kcopyd_client_create(NULL); - if (vdo->partition_copier == NULL) - return -ENOMEM; + if (IS_ERR(vdo->partition_copier)) { + result = PTR_ERR(vdo->partition_copier); + vdo->partition_copier = NULL; + return result; + } } /* Free any unused preparation. */ diff --git a/drivers/md/dm-vdo/slab-depot.c b/drivers/md/dm-vdo/slab-depot.c index 2125e256aa86..56d975c98752 100644 --- a/drivers/md/dm-vdo/slab-depot.c +++ b/drivers/md/dm-vdo/slab-depot.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -3445,8 +3446,10 @@ static void initiate_load(struct admin_state *state) handle_operation_error, allocator->thread_id, NULL); allocator->eraser = dm_kcopyd_client_create(NULL); - if (allocator->eraser == NULL) { - vdo_fail_completion(&allocator->completion, -ENOMEM); + if (IS_ERR(allocator->eraser)) { + vdo_fail_completion(&allocator->completion, + PTR_ERR(allocator->eraser)); + allocator->eraser = NULL; return; } allocator->slabs_to_erase = get_slab_iterator(allocator); -- 2.41.0