* [PATCH v3] ALSA: ymfpci: Handle return NULL error from ioremap_nocache
@ 2017-01-24 5:31 Arvind Yadav
2017-01-25 21:31 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-01-24 5:31 UTC (permalink / raw)
To: perex, tiwai; +Cc: alsa-devel, linux-kernel
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..8be1f07 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) {
+ snd_ymfpci_free(chip);
+ return -ENOMEM;
+ }
pci_set_master(pci);
chip->src441_used = -1;
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v3] ALSA: ymfpci: Handle return NULL error from ioremap_nocache
2017-01-24 5:31 [PATCH v3] ALSA: ymfpci: Handle return NULL error from ioremap_nocache Arvind Yadav
@ 2017-01-25 21:31 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2017-01-25 21:31 UTC (permalink / raw)
To: Arvind Yadav; +Cc: perex, alsa-devel, linux-kernel
On Tue, 24 Jan 2017 06:31:26 +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..8be1f07 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) {
> + snd_ymfpci_free(chip);
The function calls iounmap() unconditionally, so it's not appropriate
to call as is. You need to fix snd_ymfpci_free() as well to check
NULL before iounmap(). Or, call here kfree() and pci_disable_device()
explicitly instead of a full destructor.
thanks,
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-25 21:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 5:31 [PATCH v3] ALSA: ymfpci: Handle return NULL error from ioremap_nocache Arvind Yadav
2017-01-25 21:31 ` Takashi Iwai
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®