]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.8.5/blkcg-unlock-blkcg_pol_mutex-only-once-when-cpd-null.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.8.5 / blkcg-unlock-blkcg_pol_mutex-only-once-when-cpd-null.patch
CommitLineData
39a3a1fe
GKH
1From bbb427e342495df1cda10051d0566388697499c0 Mon Sep 17 00:00:00 2001
2From: Bart Van Assche <bart.vanassche@sandisk.com>
3Date: Thu, 29 Sep 2016 08:33:30 -0700
4Subject: blkcg: Unlock blkcg_pol_mutex only once when cpd == NULL
5
6From: Bart Van Assche <bart.vanassche@sandisk.com>
7
8commit bbb427e342495df1cda10051d0566388697499c0 upstream.
9
10Unlocking a mutex twice is wrong. Hence modify blkcg_policy_register()
11such that blkcg_pol_mutex is unlocked once if cpd == NULL. This patch
12avoids that smatch reports the following error:
13
14block/blk-cgroup.c:1378: blkcg_policy_register() error: double unlock 'mutex:&blkcg_pol_mutex'
15
16Fixes: 06b285bd1125 ("blkcg: fix blkcg_policy_data allocation bug")
17Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
18Cc: Tejun Heo <tj@kernel.org>
19Signed-off-by: Tejun Heo <tj@kernel.org>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 block/blk-cgroup.c | 4 +---
24 1 file changed, 1 insertion(+), 3 deletions(-)
25
26--- a/block/blk-cgroup.c
27+++ b/block/blk-cgroup.c
28@@ -1340,10 +1340,8 @@ int blkcg_policy_register(struct blkcg_p
29 struct blkcg_policy_data *cpd;
30
31 cpd = pol->cpd_alloc_fn(GFP_KERNEL);
32- if (!cpd) {
33- mutex_unlock(&blkcg_pol_mutex);
34+ if (!cpd)
35 goto err_free_cpds;
36- }
37
38 blkcg->cpd[pol->plid] = cpd;
39 cpd->blkcg = blkcg;