From patchwork Fri Nov 27 13:46:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 105183 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1157797lbb; Fri, 27 Nov 2015 05:47:56 -0800 (PST) X-Received: by 10.66.155.226 with SMTP id vz2mr68725748pab.18.1448632075951; Fri, 27 Nov 2015 05:47:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si8226999pfi.247.2015.11.27.05.47.55; Fri, 27 Nov 2015 05:47:55 -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 S1754250AbbK0Nro (ORCPT + 28 others); Fri, 27 Nov 2015 08:47:44 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:60140 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753314AbbK0Nrk (ORCPT ); Fri, 27 Nov 2015 08:47:40 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0LtzWQ-1aUSIf0gcA-011Vcz; Fri, 27 Nov 2015 14:46:43 +0100 From: Arnd Bergmann To: Mark Brown Cc: Peter Zijlstra , Sascha Hauer , "linux-kernel@vger.kernel.org" , Liam Girdwood , Geert Uytterhoeven , Ingo Molnar , "linux-arm-kernel@lists.infradead.org" Subject: [PATCH, RESEND] regulator: core: fix regulator_lock_supply regression Date: Fri, 27 Nov 2015 14:46:41 +0100 Message-ID: <3504080.aWa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zUZCenk2t5NsC2Oh6BDFMaufWb6GfOE9FcvPgz96GiQtI8 zG+9UjoVEM3lyE2n 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") --- rebased on top of regulators.git #for-next -- 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); }