[alsa-devel] [PATCH] ASoC: wm8962: Convert to devm_input_allocate_device()

Leon Romanovsky leon at leon.nu
Sun Apr 28 07:00:29 CEST 2013


Hi Mark,
On Thu, Apr 25, 2013 at 3:52 PM, Mark Brown <broonie at kernel.org> wrote:
> On Wed, Apr 24, 2013 at 04:50:48PM +0300, Leon Romanovsky wrote:
>> On Thu, Dec 20, 2012 at 4:18 PM, Mark Brown
>
>> >         ret = input_register_device(wm8962->beep);
>> >         if (ret != 0) {
>> > -               input_free_device(wm8962->beep);
>> >                 wm8962->beep = NULL;
>> >                 dev_err(codec->dev, "Failed to register beep device\n");
>> >         }
>
>> I'm not sure if this patch is correct.
>> According to comment of input_free_memory()
>> (http://lxr.free-electrons.com/source/drivers/input/input.c#L1825) you
>> need to call it if input_register_device failed.
>
> This seems like a bug that should be fixed on the API side, it's really
> not what you'd expect a devm function to do, and if you are explicitly
> freeing a devm allocated object there's an expectation that you need to
> call a corresponding devm cleanup function.

I can't agree with you about the "expectation" - device memory can be in use.
This code will free memory after all references will be freed.
Additionally it is up-to developer to decide what to do if
input_register_device call failed.
According to the code base
(http://lxr.free-electrons.com/ident?i=input_free_device)
the patch is not correct.

Thanks.

--
Leon Romanovsky | Independent Linux Consultant
        www.leon.nu | leon at leon.nu


More information about the Alsa-devel mailing list