mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Jerome Marchand <jmarchan@redhat.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: Re: Should snd_card_free() check for null pointer?
Date: Wed, 10 Feb 2016 09:45:30 +0100	[thread overview]
Message-ID: <s5h60xxj6mt.wl-tiwai@suse.de> (raw)
In-Reply-To: <1378691295.23400498.1455090098781.JavaMail.zimbra@redhat.com>

On Wed, 10 Feb 2016 08:41:38 +0100,
Jerome Marchand wrote:
> 
> ----- Original Message -----
> > From: "Takashi Iwai" <tiwai@suse.de>
> > To: "Jerome Marchand" <jmarchan@redhat.com>
> > Cc: "Jaroslav Kysela" <perex@perex.cz>, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
> > Sent: Tuesday, February 9, 2016 10:56:39 PM
> > Subject: Re: Should snd_card_free() check for null pointer?
> > 
> > On Tue, 09 Feb 2016 15:30:16 +0100,
> > Jerome Marchand wrote:
> > > 
> > > Hi,
> > > 
> > > Before commit f24640648186b (ALSA: Use standard device refcount for card
> > > accounting), snd_card_free() would return -EINVAL on a null pointer. Now
> > > it ends up in a null pointer dereference. There is at least one driver
> > > that can call snd_card_free() with null argument: saa7134_alsa. It can
> > > easily be triggered by just inserting and removing the module (no need
> > > to have the hardware).
> > > I don't think that is a rule, but it seems that the standard behavior of
> > > *_free() functions is to check for null pointer. What do you think?
> > 
> > Well, I have a mixed feeling about this.  Allowing NULL sometimes
> > makes the code easier.  OTOH, caling snd_card_free() with NULL is
> > really an unexpected situation, and if a driver does it, most likely
> > it does something weird.
> > 
> > So, at this moment, I would fix the caller side.  But, it's not a
> > final call, just my gut feeling.
> 
> I have no strong opinion either way and I have a patch that fixes saa7134
> driver ready to be sent if that is your preference.

Go ahead, let's fix saa7134 side for now.


thanks,

Takashi

      reply	other threads:[~2016-02-10  8:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 14:30 Jerome Marchand
2016-02-09 21:56 ` Takashi Iwai
2016-02-10  7:41   ` Jerome Marchand
2016-02-10  8:45     ` Takashi Iwai [this message]

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=s5h60xxj6mt.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=jmarchan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    /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

all inboxes | Powered by JetHome®