[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZL5Jzod5NBETv9Dp@smile.fi.intel.com>
Date: Mon, 24 Jul 2023 12:52:14 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Cc: Brent Lu <brent.lu@...el.com>, alsa-devel@...a-project.org,
Cezary Rojewski <cezary.rojewski@...el.com>,
Liam Girdwood <liam.r.girdwood@...ux.intel.com>,
Peter Ujfalusi <peter.ujfalusi@...ux.intel.com>,
Bard Liao <yung-chuan.liao@...ux.intel.com>,
Ranjani Sridharan <ranjani.sridharan@...ux.intel.com>,
Kai Vehmanen <kai.vehmanen@...ux.intel.com>,
Mark Brown <broonie@...nel.org>,
Jaroslav Kysela <perex@...ex.cz>,
Takashi Iwai <tiwai@...e.com>, linux-kernel@...r.kernel.org,
Yong Zhi <yong.zhi@...el.com>,
Ajye Huang <ajye_huang@...pal.corp-partner.google.com>,
Uday M Bhat <uday.m.bhat@...el.com>,
Terry Cheong <htcheong@...omium.org>,
Mac Chiang <mac.chiang@...el.com>,
"Dharageswari . R" <dharageswari.r@...el.com>,
Kuninori Morimoto <kuninori.morimoto.gx@...esas.com>
Subject: Re: [PATCH 1/2] ASoC: Intel: maxim-common: get codec number from ACPI
On Mon, Jul 24, 2023 at 11:08:17AM +0200, Pierre-Louis Bossart wrote:
> On 7/20/23 11:26, Brent Lu wrote:
...
> > +/* helper function to get the number of specific codec */
...and leak a lot of reference counts...
> > +static int get_num_codecs(const char *hid)
> > +{
> > + struct acpi_device *adev = NULL;
> > + int dev_num = 0;
> > +
> > + do {
> > + adev = acpi_dev_get_next_match_dev(adev, hid, NULL, -1);
>
> Humm, I am a bit worried about reference counts.
>
> See
> https://elixir.bootlin.com/linux/latest/source/drivers/acpi/utils.c#L916,
> it's not clear to me where the get() is done.
>
> Adding Andy to make sure this is done right.
Thank you for Cc'ing.
Yes, the above code is problematic. One has to use the respective for_each
macro (defined nearby the used API).
> > + if (adev)
> > + dev_num++;
> > + } while (adev != NULL);
> > +
> > + return dev_num;
> > +}
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists