Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1367666

Re: [PATCH] regulator: Fix deadlock during regulator registration

From Javier Martinez Canillas <javier@osg.samsung.com>
Newsgroups linux.kernel
Subject Re: [PATCH] regulator: Fix deadlock during regulator registration
Date 2016-03-31 01:30 +0200
Message-ID <rixIK-4bU-17@gated-at.bofh.it> (permalink)
References <riqQV-7Ua-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello Jon,

On 03/30/2016 12:09 PM, Jon Hunter wrote:
> Commit 5e3ca2b349b1 ("regulator: Try to resolve regulators supplies on
> registration") added a call to regulator_resolve_supply() within
> regulator_register() where the regulator_list_mutex is held. This causes
> the following deadlock to occur on the Tegra114 Dalmore board when the
> palmas PMIC is registered because regulator_register_resolve_supply()
> calls regulator_dev_lookup() which may try to acquire the
> regulator_list_mutex again.
>

Sorry for missing that. I didn't notice because on my machine the regulators
are looked up using OF and in that case the regulator_list_mutex isn't grabbed.

I believe your patch is correct, I have just one trivial comment below:

>  
> @@ -4016,15 +4015,16 @@ scrub:
>  	regulator_ena_gpio_free(rdev);
>  	device_unregister(&rdev->dev);
>  	/* device core frees rdev */
> -	rdev = ERR_PTR(ret);
>  	goto out;
>  
>  wash:
>  	regulator_ena_gpio_free(rdev);
>  clean:
>  	kfree(rdev);
> -	rdev = ERR_PTR(ret);

You are doing some cleanup of the clean and scrub error paths by removing
rdev and returning ERR_PTR(ret) directly. I believe that should be in a
separate patch since is not related to the fix.

> -	goto out;
> +out:
> +	mutex_unlock(&regulator_list_mutex);
> +	kfree(config);
> +	return ERR_PTR(ret);
>  }
>  EXPORT_SYMBOL_GPL(regulator_register);
>  
> 

If you split the cleanup and address Mark's comments, feel free to add:

Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com>

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] regulator: Fix deadlock during regulator registration Jon Hunter <jonathanh@nvidia.com> - 2016-03-30 18:10 +0200
  Re: [PATCH] regulator: Fix deadlock during regulator registration Mark Brown <broonie@kernel.org> - 2016-03-30 18:20 +0200
    Re: [PATCH] regulator: Fix deadlock during regulator registration Jon Hunter <jonathanh@nvidia.com> - 2016-03-30 18:50 +0200
      Re: [PATCH] regulator: Fix deadlock during regulator registration Mark Brown <broonie@kernel.org> - 2016-03-30 19:10 +0200
        Re: [PATCH] regulator: Fix deadlock during regulator registration Jon Hunter <jonathanh@nvidia.com> - 2016-03-30 19:50 +0200
  Re: [PATCH] regulator: Fix deadlock during regulator registration Javier Martinez Canillas <javier@osg.samsung.com> - 2016-03-31 01:30 +0200
    Re: [PATCH] regulator: Fix deadlock during regulator registration Javier Martinez Canillas <javier@osg.samsung.com> - 2016-03-31 01:40 +0200
    Re: [PATCH] regulator: Fix deadlock during regulator registration Mark Brown <broonie@kernel.org> - 2016-03-31 01:40 +0200

csiph-web