verity_parse_opt_args is called twice, first with the only_modifier_opts,
first with only_modifier_opts == true and then with only_modifier_opts ==
false. Thus, the static branch &use_bh_wq_enabled was incremented twice
and the destructor verity_dtr would only decrement it once.

Fix tihs bug by only incrementing it on the first call, on the second
call, when v->use_bh_wq is true, do nothing.

Signed-off-by: Mikulas Patocka <[email protected]>
Assisted-by: Claude:claude-opus-4-6
Cc: [email protected]
Fixes: df326e7a0699 ("dm verity: allow optional args to alter primary args 
handling")

---
 drivers/md/dm-verity-target.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6/drivers/md/dm-verity-target.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-verity-target.c        2026-07-01 
13:24:34.000000000 +0200
+++ linux-2.6/drivers/md/dm-verity-target.c     2026-07-01 13:31:00.000000000 
+0200
@@ -1262,6 +1262,8 @@ static int verity_parse_opt_args(struct
                        continue;
 
                } else if (!strcasecmp(arg_name, DM_VERITY_OPT_TASKLET_VERIFY)) 
{
+                       if (v->use_bh_wq)
+                               continue;
                        v->use_bh_wq = true;
                        static_branch_inc(&use_bh_wq_enabled);
                        continue;


Reply via email to