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 <[email protected]>
Reviewed-by: Alexander Ivanov <[email protected]>
---
v2: no changes
v3: no changes
v4: 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

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to