linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: k.marinushkin@gmail.com (Kirill Marinushkin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] staging: bcm2835-audio: Release resources on module_exit()
Date: Thu, 15 Mar 2018 06:57:21 +0100	[thread overview]
Message-ID: <1a59a938-0381-49f4-dfd9-c7a52bdb0eae@gmail.com> (raw)
In-Reply-To: <CAHp75Ve9MRAgSu74Mzr2defd84umyeKpfvX51-Qhk4SvLx3Qng@mail.gmail.com>

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.

>
>>         device_unregister(childdev);
>>  }
>> +static void snd_devm_release(struct device *dev)
>> +{
>> +       struct bcm2835_chip *chip = dev_get_drvdata(dev);
>> +
>> +       kfree(chip);
>> +}
>
>>  /* chip-specific constructor
>> @@ -122,7 +136,7 @@ static int snd_bcm2835_create(struct snd_card *card,
>>
>>         err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
>>         if (err) {
>> -               snd_bcm2835_free(chip);
>> +               kfree(chip);
> Do you call device_register() inside snd_device_new()?
> In this case you might need put_device() here instead of simple kfree().

No, from what I see, device_register() does not happen inside snd_device_new().

>>                 return err;
>>         }

  reply	other threads:[~2018-03-15  5:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-05  5:52 [PATCH] staging: bcm2835-audio: Release resources on module_exit() Kirill Marinushkin
2018-03-06 12:14 ` Greg Kroah-Hartman
2018-03-06 17:42   ` Kirill Marinushkin
2018-03-13 19:34     ` [PATCH v2] " Kirill Marinushkin
2018-03-13 21:23       ` Andy Shevchenko
2018-03-15  5:57         ` Kirill Marinushkin [this message]
2018-03-21 15:03           ` Andy Shevchenko
2018-03-21 16:58             ` Kirill Marinushkin
2018-03-21 18:48               ` [PATCH v3] " Kirill Marinushkin
2018-03-21 19:24                 ` Andy Shevchenko
2018-03-21 19:51                   ` Kirill Marinushkin
2018-03-22 21:21                   ` Kirill Marinushkin
2018-03-22 21:37                     ` [PATCH v4] " Kirill Marinushkin
2018-03-23 16:23                       ` Andy Shevchenko
2018-03-23 19:22                         ` Kirill Marinushkin
2018-03-25 10:33                           ` Andy Shevchenko
2018-03-25 10:44                             ` Kirill Marinushkin
2018-03-25 13:03                               ` Andy Shevchenko
2018-03-25 13:54                                 ` Kirill Marinushkin
2018-03-23 19:32                         ` [PATCH v5] " Kirill Marinushkin
2018-03-25 10:33                           ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1a59a938-0381-49f4-dfd9-c7a52bdb0eae@gmail.com \
    --to=k.marinushkin@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).