From patchwork Fri Nov 27 12:04:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105186 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1096932lbb; Fri, 27 Nov 2015 04:05:39 -0800 (PST) X-Received: by 10.66.164.234 with SMTP id yt10mr44412052pab.11.1448625939249; Fri, 27 Nov 2015 04:05:39 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc9si16079199pad.140.2015.11.27.04.05.38; Fri, 27 Nov 2015 04:05:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754734AbbK0MFh (ORCPT + 28 others); Fri, 27 Nov 2015 07:05:37 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:53351 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753505AbbK0MFe (ORCPT ); Fri, 27 Nov 2015 07:05:34 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue004) with ESMTPSA (Nemesis) id 0MeOeR-1Zfxmw0d7H-00Q920; Fri, 27 Nov 2015 13:04:33 +0100 From: Arnd Bergmann To: Mark Brown Cc: Ingo Molnar , "linux-arm-kernel@lists.infradead.org" , Peter Zijlstra , Sascha Hauer , Liam Girdwood , "linux-kernel@vger.kernel.org" , Geert Uytterhoeven Subject: [PATCH] regulator: core: fix regulator_lock_supply regression Date: Fri, 27 Nov 2015 13:04:30 +0100 Message-ID: <3399746.xt7N4lig0U@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:EzB3h6+uck/tF6BtQUHCVJfyKtfAouP/5huiVibalscxrDqBxVD tnx89qM6ZXL1ewauB7MKyQhDHrAz3g4SKGVWTpOuoXEourtqkPhMj/w5cu9d6xKz0c4ad+w 7s7C+OcZ+CkuMzyDtWOReYyIGFlke7NdLiNdEoHQXQx6WQ1hef2vrz6ED+xHRJZhVJf+T3P wU/v5NQYkJE2QnicjwJdw== X-UI-Out-Filterresults: notjunk:1; V01:K0:E5OcajYPSwg=:EmJdqur0Ah42yT6xLNdUPj 5NmrdZ6sC/jjx4vqsXBwuNF9X67KpIbIX2HlmrhaR1/9zLABmze5+8kELzzT6hDsicxt5nQpb LNtji8Sj5OreDiYRuHCUZcCPEtiTrDPquLfCSQSlr1+IU9coULybQ4uRpoBIj13byo3nAq6c6 l6n3ZCiGI4JA0MDMv43pPJSnCo1+F69IpOksJlpVdyVpuJuq1u7M/Lvv6jTSxHxOUudmQPrD0 poVtw1GuKx9GvhenxD2uhcWERKD8T4wb5LvvJFWaHK4bb17U4OJlcgrTi6WQr+cbSkNpv+6NI Bt6Wx6T5sC6vevRr12CeQ10C2bUuyoiIXdx3BIKEFRM/cU6ea+Kq0THZtkiZoL0Th0yNpySsx dQ0/cyJJGr5ToHcyF32qMb00uMuqmR189GdpofhPy9UtR3QS4slUyok3TrQU881cDOmEJ5v+g pLQOQ8THfUM2DuTFAHefcy3MecYyLH7U/wQ1whgVpjXrTM3hJ9nDgb19raSboF7A1xn9PLZA3 F3Jf5OsFYOxG0sNL0OrQfDaZHEnEu5sT0L0/QklrA/kcu8l3a0EQY03s6rfMLuNwBekS7aRHZ MAObL15QAn7kW41H45/vX5l/IprVgIv6W3rNiZANeuu+WfxKLPPAEsSPd6lCTcPpEHWP1zWBZ IgH37YPrFjWApS/xQMOmhehIdYuNydNZLyeGgMFColQQcVCwruJqqnY6oCWOwFMugeuNDx6Y3 eT1VI27wSPo8Dzqj Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As noticed by Geert Uytterhoeven, my patch to avoid a harmless build warning in regulator_lock_supply() was total crap and introduced a real bug: > [ BUG: bad unlock balance detected! ] > kworker/u4:0/6 is trying to release lock (&rdev->mutex) at: > [] regulator_set_voltage+0x38/0x50 We still lock the regulator supplies, but not the actual regulators, so we are missing a lock, and the unlock is unbalanced. This rectifies it by first locking the regulator device itself before using the same loop as before to lock its supplies. Reported-by: Geert Uytterhoeven Signed-off-by: Arnd Bergmann Fixes: 716fec9d1965 ("[SUBMITTED] regulator: core: avoid unused variable warning") --- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c9bdca5f3b9b..89e4dcb84758 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -140,7 +140,8 @@ static void regulator_lock_supply(struct regulator_dev *rdev) { int i; - for (i = 0; rdev->supply; rdev = rdev->supply->rdev, i++) + mutex_lock(&rdev->mutex); + for (i = 1; rdev->supply; rdev = rdev->supply->rdev, i++) mutex_lock_nested(&rdev->mutex, i); }