dm-verity parses optional arguments twice during target construction.
When `try_verify_in_tasklet` is present, each parse pass increments the
`use_bh_wq_enabled` static key, but the target destructor decrements it
only once.

Creating and removing such a target can therefore leave the static key
enabled after the target is gone.

Only increment the static key when the option first enables tasklet
verification for the target.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <[email protected]>
---
 drivers/md/dm-verity-target.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 9a9847f94c46..c06ccf7ee1b9 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -1262,8 +1262,10 @@ static int verity_parse_opt_args(struct dm_arg_set *as, 
struct dm_verity *v,
                        continue;
 
                } else if (!strcasecmp(arg_name, DM_VERITY_OPT_TASKLET_VERIFY)) 
{
-                       v->use_bh_wq = true;
-                       static_branch_inc(&use_bh_wq_enabled);
+                       if (!v->use_bh_wq) {
+                               v->use_bh_wq = true;
+                               static_branch_inc(&use_bh_wq_enabled);
+                       }
                        continue;
 
                } else if (verity_is_fec_opt_arg(arg_name)) {
-- 
2.43.0


Reply via email to