mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Krzysztof Helt <krzysztof.h1@wp.pl>
Cc: Lubomir Rintel <lkundrak@v3.sk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-sound@vger.kernel.org, stable@kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Fix NULL dereference when suspending snd_opl3sa2
Date: Tue, 17 Mar 2009 09:30:34 +0100	[thread overview]
Message-ID: <s5h3adczh3p.wl%tiwai@suse.de> (raw)
In-Reply-To: <20090316213225.5d59aca1.krzysztof.h1@wp.pl>

At Mon, 16 Mar 2009 21:32:25 +0100,
Krzysztof Helt wrote:
> 
> On Mon, 16 Mar 2009 15:16:08 +0100
> Lubomir Rintel <lkundrak@v3.sk> wrote:
> 
> > On Mon, 2009-03-16 at 11:01 +0100, Lubomir Rintel wrote:
> > > This should fix the following OOPS:
> > > http://www.kerneloops.org/raw.php?rawid=80591&msgid=
> > 
> 
> > This is the same issue, with 2.6.28:
> > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=519939
> > 
> > 
> 
> One should no force loading of the snd-opl3sa2 driver
> in the above cases. It was forced as the opl3sa2 is a PnP chip
> and the drivers were loaded as plain ISA devices.
> 
> However, this is not a cause of the OOPS. The cause is that
> despite the driver returns -ENODEV, the higher layer
> hides it and the driver is bound to the bus. I suppose,
> the suspend and resume functions are called on it.
> 
> Look at the ISA probe function:
> 
> static int __devinit snd_opl3sa2_isa_probe(struct device *pdev,
>                        unsigned int dev)
> {
>     struct snd_card *card;
>     int err;
> 
>     card = snd_opl3sa2_card_new(dev);
>     if (! card)
>         return -ENOMEM;
>     snd_card_set_dev(card, pdev);
>     if ((err = snd_opl3sa2_probe(card, dev)) < 0) {
>         snd_card_free(card);
>         return err;
>     }
>     dev_set_drvdata(pdev, card);
>     return 0;
> }
> 
> If the probe function fails, the drvdata is
> never set to the snd_card structure pointer.
> 
> The patch below should fix suspend and resume
> functions.
> 
> Regards,
> Krzysztof
> PS. It is the same situation for PnP and
> BIOS PnP probing in this driver.
> ---
> 
> Fix the OOPS during a opl3sa2 card suspend
> and resume if the driver is loaded but the card
> is not found.
> 
> Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>

This patch looks good.  I applied it to sound git tree now.

Thanks,

Takashi


> --- a/sound/isa/opl3sa2.c~	2008-10-13 18:03:52.000000000 +0200
> +++ b/sound/isa/opl3sa2.c	2009-03-16 21:20:30.841348261 +0100
> @@ -550,21 +550,27 @@ static int __devinit snd_opl3sa2_mixer(s
>  #ifdef CONFIG_PM
>  static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state)
>  {
> -	struct snd_opl3sa2 *chip = card->private_data;
> +	if (card) {
> +		struct snd_opl3sa2 *chip = card->private_data;
>  
> -	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
> -	chip->wss->suspend(chip->wss);
> -	/* power down */
> -	snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
> +		snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
> +		chip->wss->suspend(chip->wss);
> +		/* power down */
> +		snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3);
> +	}
>  
>  	return 0;
>  }
>  
>  static int snd_opl3sa2_resume(struct snd_card *card)
>  {
> -	struct snd_opl3sa2 *chip = card->private_data;
> +	struct snd_opl3sa2 *chip;
>  	int i;
>  
> +	if (!card)
> +		return 0;
> +
> +	chip = card->private_data;
>  	/* power up */
>  	snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0);
>  
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

      reply	other threads:[~2009-03-17  8:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-16 10:01 Lubomir Rintel
2009-03-16 14:16 ` Lubomir Rintel
2009-03-16 18:21   ` Krzysztof Helt
2009-03-16 20:32   ` Krzysztof Helt
2009-03-17  8:30     ` 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=s5h3adczh3p.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=krzysztof.h1@wp.pl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=lkundrak@v3.sk \
    --cc=stable@kernel.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

all inboxes | Powered by JetHome®