mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Arvind Yadav" <arvind.yadav.cs@gmail.com>
Cc: <perex@perex.cz>, <alsa-devel@alsa-project.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] ALSA: ymfpci:  Handle return NULL error from ioremap_nocache
Date: Mon, 23 Jan 2017 14:20:10 +0100	[thread overview]
Message-ID: <s5ha8ahq5f9.wl-tiwai@suse.de> (raw)
In-Reply-To: <1485156988-24137-1-git-send-email-arvind.yadav.cs@gmail.com>

On Mon, 23 Jan 2017 08:36:28 +0100,
Arvind Yadav wrote:
> 
> Here, If ioremap_nocache will fail. It will return NULL.
> Kernel can run into a NULL-pointer dereference.
> This error check will avoid NULL pointer dereference.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  sound/pci/ymfpci/ymfpci_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
> index ffee284..8590c3f 100644
> --- a/sound/pci/ymfpci/ymfpci_main.c
> +++ b/sound/pci/ymfpci/ymfpci_main.c
> @@ -2392,6 +2392,10 @@ int snd_ymfpci_create(struct snd_card *card,
>  	chip->rev = pci->revision;
>  	chip->reg_area_phys = pci_resource_start(pci, 0);
>  	chip->reg_area_virt = ioremap_nocache(chip->reg_area_phys, 0x8000);
> +	if (!chip->reg_area_virt) {
> +		pci_disable_device(pci);
> +		return -ENOMEM;

You forgot to release chip.  Otherwise it leads memory.


thanks,

Takashi

      reply	other threads:[~2017-01-23 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23  7:36 Arvind Yadav
2017-01-23 13:20 ` 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=s5ha8ahq5f9.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=arvind.yadav.cs@gmail.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®