From patchwork Tue Apr 12 07:08:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 104953 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1760694qge; Tue, 12 Apr 2016 00:08:36 -0700 (PDT) X-Received: by 10.66.199.66 with SMTP id ji2mr2504745pac.34.1460444916488; Tue, 12 Apr 2016 00:08:36 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si8587683pai.104.2016.04.12.00.08.36; Tue, 12 Apr 2016 00:08:36 -0700 (PDT) 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 S1756152AbcDLHIe (ORCPT + 29 others); Tue, 12 Apr 2016 03:08:34 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:34280 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbcDLHId (ORCPT ); Tue, 12 Apr 2016 03:08:33 -0400 Received: from debutante.sirena.org.uk ([2a01:348:6:8808:fab::3] helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1apsR1-000490-3M; Tue, 12 Apr 2016 07:08:28 +0000 Received: from broonie by debutante with local (Exim 4.87) (envelope-from ) id 1apsQw-0002ue-9F; Tue, 12 Apr 2016 08:08:22 +0100 From: Mark Brown To: Liam Girdwood Cc: linux-kernel@vger.kernel.org, Mark Brown Date: Tue, 12 Apr 2016 08:08:21 +0100 Message-Id: <1460444901-11158-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.8.0.rc3 X-SA-Exim-Connect-IP: 2a01:348:6:8808:fab::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 Subject: [PATCH] regulator: core: Fix locking of GPIO list on free X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we acquire a shareable enable GPIO on probe we do so with the regulator_list_mutex held. However when we release the GPIOs we do this immediately after dropping the mutex meaning that the list could become corrupted. Move the release into the locked region to avoid this. Signed-off-by: Mark Brown --- drivers/regulator/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.8.0.rc3 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 85d3a746f58a..62ca85c20ff9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4066,8 +4066,8 @@ void regulator_unregister(struct regulator_dev *rdev) WARN_ON(rdev->open_count); unset_regulator_supplies(rdev); list_del(&rdev->list); - mutex_unlock(®ulator_list_mutex); regulator_ena_gpio_free(rdev); + mutex_unlock(®ulator_list_mutex); device_unregister(&rdev->dev); } EXPORT_SYMBOL_GPL(regulator_unregister);