]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm vdo: fix how dm_kcopyd_client_create() failure is checked
authorMike Snitzer <snitzer@kernel.org>
Fri, 1 Dec 2023 00:54:56 +0000 (19:54 -0500)
committerMike Snitzer <snitzer@kernel.org>
Tue, 20 Feb 2024 18:43:17 +0000 (13:43 -0500)
dm_kcopyd_client_create() returns an ERR_PTR so its return must be
checked with IS_ERR().

Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Chung Chung <cchung@redhat.com>
Signed-off-by: Matthew Sakai <msakai@redhat.com>
drivers/md/dm-vdo-target.c
drivers/md/dm-vdo/slab-depot.c

index 72d2291dd93f263fd4695bbf9851cc00aafe5629..4fbc148681e51746b9dbdbb6766ec2e43598a1c4 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/completion.h>
 #include <linux/delay.h>
 #include <linux/device-mapper.h>
+#include <linux/err.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/spinlock.h>
@@ -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. */
index 2125e256aa86ce2523ace5d1a286dbca0dda811b..56d975c987526bb7566c6f808f3259ff5e85a472 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/atomic.h>
 #include <linux/bio.h>
+#include <linux/err.h>
 #include <linux/log2.h>
 #include <linux/min_heap.h>
 #include <linux/minmax.h>
@@ -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);