[Devel] [PATCH hci-8.1 v6 1/7] dm/push_backup: correct initialization
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Wed Nov 4 11:38:12 MSK 2026
Allocate pool and htable after lock, waitqueue and deadline
timer init so that pb_destroy() is safe on every error path
of pb_ctr(). Otherwise a failed allocation makes pb_destroy()
call timer_delete_sync_try() on a zeroed timer struct. This
happens to work on release kernels, but with
CONFIG_DEBUG_OBJECTS_TIMERS=y debug_assert_init() reports the
uninitialized timer with an ODEBUG warning.
https://virtuozzo.atlassian.net/browse/VSTOR-152912
Feature: dm-backup: push backup target driver
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Reviewed-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
---
v2: no changes
v3: no changes
v4: no changes
v5: commit message: safe on every error path of pb_ctr(); the
zeroed timer triggers an ODEBUG warning with
CONFIG_DEBUG_OBJECTS_TIMERS=y
v6: subject prefix changed to dm/push_backup, added Feature: tag
drivers/md/dm-push-backup.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/drivers/md/dm-push-backup.c b/drivers/md/dm-push-backup.c
index 885ea7b31cf67..9a6252f2b21e2 100644
--- a/drivers/md/dm-push-backup.c
+++ b/drivers/md/dm-push-backup.c
@@ -658,24 +658,22 @@ static int pb_ctr(struct dm_target *ti, unsigned int argc, char **argv)
pb = kzalloc(sizeof(*pb), GFP_KERNEL);
if (!pb)
goto err;
-
- pb->pbio_pool = mempool_create_slab_pool(PUSH_BACKUP_POOL_SIZE,
- pbio_cache);
- pb->pending_htable = kcalloc(PB_HASH_TABLE_SIZE,
- sizeof(struct hlist_head),
- GFP_KERNEL);
- if (!pb->pbio_pool || !pb->pending_htable)
- goto err;
-
spin_lock_init(&pb->lock);
init_rwsem(&pb->ctl_rwsem);
bio_list_init(&pb->deferred_bios);
INIT_LIST_HEAD(&pb->pending);
timer_setup(&pb->deadline_timer, pb_timer_func, 0);
-
init_waitqueue_head(&pb->waitq);
INIT_WORK(&pb->worker, do_pb_work);
+ pb->pbio_pool = mempool_create_slab_pool(PUSH_BACKUP_POOL_SIZE,
+ pbio_cache);
+ pb->pending_htable = kcalloc(PB_HASH_TABLE_SIZE,
+ sizeof(struct hlist_head),
+ GFP_KERNEL);
+ if (!pb->pbio_pool || !pb->pending_htable)
+ goto err;
+
ti->private = pb;
pb->ti = ti;
--
2.43.5
More information about the Devel
mailing list