]> Git Repo - linux.git/commitdiff
blkcg: Unlock blkcg_pol_mutex only once when cpd == NULL
authorBart Van Assche <[email protected]>
Thu, 29 Sep 2016 15:33:30 +0000 (08:33 -0700)
committerTejun Heo <[email protected]>
Fri, 30 Sep 2016 08:31:20 +0000 (10:31 +0200)
Unlocking a mutex twice is wrong. Hence modify blkcg_policy_register()
such that blkcg_pol_mutex is unlocked once if cpd == NULL. This patch
avoids that smatch reports the following error:

block/blk-cgroup.c:1378: blkcg_policy_register() error: double unlock 'mutex:&blkcg_pol_mutex'

Fixes: 06b285bd1125 ("blkcg: fix blkcg_policy_data allocation bug")
Signed-off-by: Bart Van Assche <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: <[email protected]> # v4.2+
Signed-off-by: Tejun Heo <[email protected]>
block/blk-cgroup.c

index dd38e5ced4a3fa7510f00c2ee7ff9dc636b2a7fc..b08ccbb9393a75800a3299f90537f6ee881b00f0 100644 (file)
@@ -1340,10 +1340,8 @@ int blkcg_policy_register(struct blkcg_policy *pol)
                        struct blkcg_policy_data *cpd;
 
                        cpd = pol->cpd_alloc_fn(GFP_KERNEL);
-                       if (!cpd) {
-                               mutex_unlock(&blkcg_pol_mutex);
+                       if (!cpd)
                                goto err_free_cpds;
-                       }
 
                        blkcg->cpd[pol->plid] = cpd;
                        cpd->blkcg = blkcg;
This page took 0.060085 seconds and 4 git commands to generate.