[Devel] [PATCH hci-8.1 v2 1/6] drivers/md/push_backup: correct initialization
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Nov 3 03:32:41 MSK 2026
Allocate pool and htable after lock, waitqueue and deadline
timer init so we are sure that pb_destroy() can be called
from anywhere. Otherwise we risk timer_delete_sync_try on
zeroed timer struct (currently luckily fine).
https://virtuozzo.atlassian.net/browse/VSTOR-152912
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
v2: no changes
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