lkml.org 
[lkml]   [2018]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] staging: bcm2835-audio: Release resources on module_exit()
On Thu, Mar 15, 2018 at 7:57 AM, Kirill Marinushkin
<k.marinushkin@gmail.com> wrote:
> On 03/13/18 22:23, Andy Shevchenko wrote:
>> On Tue, Mar 13, 2018 at 9:34 PM, Kirill Marinushkin
>> <k.marinushkin@gmail.com> wrote:
>>> In the current implementation, `rmmod snd_bcm2835` does not release
>>> resources properly. It causes an oops when trying to list sound devices.
>>>
>>> This commit fixes it.
>> Nice catch!
>>
>> See my comments below.
>>
>>> static void snd_devm_unregister_child(struct device *dev, void *res)
>>> {
>>> struct device *childdev = *(struct device **)res;
>>> + struct bcm2835_chip *chip = dev_get_drvdata(childdev);
>>> + struct snd_card *card = chip->card;
>>> +
>>> + snd_card_free(card);
>>> + dev_set_drvdata(childdev, NULL);
>> AFAIU this is done by device core.
>
> Maybe you are right. But I don't know, which function in the device core does it.
> It is safe to have this line. So, I suggest to keep it.

Please, remove.
If you don't know, perhaps you need to spend more time on doing homework?

% git grep -n -w dev_set_drvdata -- drivers/base/dd.c
drivers/base/dd.c:469: dev_set_drvdata(dev, NULL);
drivers/base/dd.c:499: dev_set_drvdata(dev, NULL);
drivers/base/dd.c:902: dev_set_drvdata(dev, NULL);

Last one is the point of your interest.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2018-03-21 16:04    [W:0.135 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site