ALSA: ymfpci: Handle return NULL error from ioremap_nocache
PATCH v2 1/1 ALSA: ymfpci: Handle return NULL error from ioremap_nocache
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 <[email protected]>
--- sound/pci/ymfpci/ymfpci_main.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/pci/ymfpci/ymfpci_main.c +4 -0
@@ -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 ;
Signature · 1 line
1.9.1
Quoted 15 lines · Arvind Yadav
Here, If
ioremap_nocachewill 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 <[email protected]>--- sound/pci/ymfpci/ymfpci_main.c | 4 ++++ 1 file changed, 4 insertions(+)sound/pci/ymfpci/ymfpci_main.c +0
-0
sound/pci/ymfpci/ymfpci_main.c int snd_ymfpci_create(struct snd_card *card, · line 2397
Quoted 6 lines
sound/pci/ymfpci/ymfpci_main.c +3
-0@@ -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