Skip to content

Commit

Permalink
blkcg: Unlock blkcg_pol_mutex only once when cpd == NULL
Browse files Browse the repository at this point in the history
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: 06b285b ("blkcg: fix blkcg_policy_data allocation bug")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: <stable@vger.kernel.org> # v4.2+
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Bart Van Assche authored and htejun committed Sep 30, 2016
1 parent e022300 commit bbb427e
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit bbb427e

Please sign in to comment.