All of lore.kernel.org
 help / color / mirror / Atom feed
* Make snd_card_free() a no-op again for NULL ptr argument
@ 2017-06-29 10:46 Delio Brignoli
  2017-06-29 10:49 ` Takashi Iwai
  0 siblings, 1 reply; 3+ messages in thread
From: Delio Brignoli @ 2017-06-29 10:46 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel

Hello Takashi,

Commit “ALSA: Use standard device refcount for card accounting” <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/sound/core/init.c?h=v4.12-rc6&id=f24640648186b59bd39f8cd640d631bdb61a3197> changed the behaviour of snd_card_free() in case of a NULL ptr argument. Before f24640648186b59bd39f8cd640d631bdb61a3197 snd_card_free() was a no-op in case of a NULL ptr argument as I would expect for a *_free() function. Currently passing a NULL ptr results in a NULL ptr dereference.

I believe the previous behaviour is worth restoring. If you agree I’ll follow up with a patch.

Thank you.
—
Delio



_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Make snd_card_free() a no-op again for NULL ptr argument
  2017-06-29 10:46 Make snd_card_free() a no-op again for NULL ptr argument Delio Brignoli
@ 2017-06-29 10:49 ` Takashi Iwai
  2017-06-29 11:31   ` Delio Brignoli
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Iwai @ 2017-06-29 10:49 UTC (permalink / raw)
  To: Delio Brignoli; +Cc: alsa-devel

On Thu, 29 Jun 2017 12:46:33 +0200,
Delio Brignoli wrote:
> 
> Hello Takashi,
> 
> Commit “ALSA: Use standard device refcount for card accounting” <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/sound/core/init.c?h=v4.12-rc6&id=f24640648186b59bd39f8cd640d631bdb61a3197> changed the behaviour of snd_card_free() in case of a NULL ptr argument. Before f24640648186b59bd39f8cd640d631bdb61a3197 snd_card_free() was a no-op in case of a NULL ptr argument as I would expect for a *_free() function. Currently passing a NULL ptr results in a NULL ptr dereference.
> 
> I believe the previous behaviour is worth restoring. If you agree I’ll follow up with a patch.

In which situation do you need to pass NULL to snd_card_free()?


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Make snd_card_free() a no-op again for NULL ptr argument
  2017-06-29 10:49 ` Takashi Iwai
@ 2017-06-29 11:31   ` Delio Brignoli
  0 siblings, 0 replies; 3+ messages in thread
From: Delio Brignoli @ 2017-06-29 11:31 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel


> On 29 Jun 2017, at 12:49, Takashi Iwai <tiwai@suse.de> wrote:
> 
> On Thu, 29 Jun 2017 12:46:33 +0200,
> Delio Brignoli wrote:
>> 
>> Hello Takashi,
>> 
>> Commit “ALSA: Use standard device refcount for card accounting” <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/sound/core/init.c?h=v4.12-rc6&id=f24640648186b59bd39f8cd640d631bdb61a3197> changed the behaviour of snd_card_free() in case of a NULL ptr argument. Before f24640648186b59bd39f8cd640d631bdb61a3197 snd_card_free() was a no-op in case of a NULL ptr argument as I would expect for a *_free() function. Currently passing a NULL ptr results in a NULL ptr dereference.
>> 
>> I believe the previous behaviour is worth restoring. If you agree I’ll follow up with a patch.
> 
> In which situation do you need to pass NULL to snd_card_free()?

Unconditional calls to snd_card_free(), similarly to unconditional calls to free().

struct snd_card *card = NULL;
…
/* setup code */
if (something_goes_wrong)
  goto cleanup;
…
retval = snd_card_new(…, &card);
…
cleanup:
  snd_card_free(card);
...

Sure, code can be re-organized to avoid it but *_free() function being a no-op in case of NULL ptr argument is the norm AFAIK. If so then why snd_card_free() should be different especially if it was doing the "right" thing before.

Thank you
--
Delio



_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-29 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 10:46 Make snd_card_free() a no-op again for NULL ptr argument Delio Brignoli
2017-06-29 10:49 ` Takashi Iwai
2017-06-29 11:31   ` Delio Brignoli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.