From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753683AbcBWOPd (ORCPT ); Tue, 23 Feb 2016 09:15:33 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:4240 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753126AbcBWOP2 (ORCPT ); Tue, 23 Feb 2016 09:15:28 -0500 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Tue, 23 Feb 2016 06:15:22 -0800 Subject: Re: regulator: core: Request GPIO before creating sysfs entries To: Krzysztof Adamski References: <1456129440-28143-1-git-send-email-krzysztof.adamski@tieto.com> <56CC5D1E.6010101@nvidia.com> <20160223135650.GA19954@box2.japko.eu> CC: Mark Brown , "linux-tegra@vger.kernel.org" , Linux Kernel Mailing List From: Jon Hunter Message-ID: <56CC6979.3050305@nvidia.com> Date: Tue, 23 Feb 2016 14:15:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <20160223135650.GA19954@box2.japko.eu> X-Originating-IP: [10.21.132.159] X-ClientProxiedBy: UKMAIL102.nvidia.com (10.26.138.15) To UKMAIL102.nvidia.com (10.26.138.15) Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Krzysztof, On 23/02/16 13:56, Krzysztof Adamski wrote: > On Tue, Feb 23, 2016 at 01:22:38PM +0000, Jon Hunter wrote: >> Hi Mark, Krzysztof, >> >> It appears that commit daad134d6649 ("regulator: core: Request GPIO >> before creating sysfs entries") breaks boot on tegra124-nyan-big in >> -next today. >> >> Looking at the change, it does not appear that the exit path has been >> updated correctly and so if a regulator is deferred then there is a >> crash in the exit path. I am not sure that there is a simple way to >> workaround this because of fix from commit 53032dafc6b9 ("regulator >> core: fix double-free in regulator_register() error path") unless we >> move regulator_ena_gpio_free() into regulator_dev_release(). > > Hi Jon, > > You are totally right about the problem but I can't see why changing > "goto wash" to "goto clean" in error path of regulator_ena_gpio_request > is not enough. What am I missing? So device_unregister() will call regulator_dev_release() which will free rdev (see commit 53032dafc6b9). However, rdev is needed by regulator_ena_gpio_free() and therefore, we need to call regulator_ena_gpio_free() before we call device_unregister(). So swapping the order will cause other problems. One possibility would be to move regulator_ena_gpio_free() into regulator_dev_release(). If did we could remove the regulator_ena_gpio_free() from regulator_unregister(). However, I have not looked at that in great detail. May be Mark can comment if that would be ok. Cheers Jon