Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1564734 > unrolled thread
| Started by | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| First post | 2017-01-23 08:40 +0100 |
| Last post | 2017-01-23 14:30 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2] ALSA: ymfpci: Handle return NULL error from ioremap_nocache Arvind Yadav <arvind.yadav.cs@gmail.com> - 2017-01-23 08:40 +0100
Re: [PATCH v2] ALSA: ymfpci: Handle return NULL error from ioremap_nocache Takashi Iwai <tiwai@suse.de> - 2017-01-23 14:30 +0100
| From | Arvind Yadav <arvind.yadav.cs@gmail.com> |
|---|---|
| Date | 2017-01-23 08:40 +0100 |
| Subject | [PATCH v2] ALSA: ymfpci: Handle return NULL error from ioremap_nocache |
| Message-ID | <t2Hom-3y2-35@gated-at.bofh.it> |
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;
+ }
pci_set_master(pci);
chip->src441_used = -1;
--
1.9.1
[toc] | [next] | [standalone]
| From | Takashi Iwai <tiwai@suse.de> |
|---|---|
| Date | 2017-01-23 14:30 +0100 |
| Message-ID | <t2MR3-6Yy-7@gated-at.bofh.it> |
| In reply to | #1564734 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web