mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] sound: pci: ymfpci: ymfpci_main:- Handle return NULL error from ioremap_nocache
@ 2017-01-23  7:10 Arvind Yadav
  2017-01-23  7:24 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Arvind Yadav @ 2017-01-23  7:10 UTC (permalink / raw)
  To: perex, tiwai; +Cc: Julia.Lawall, 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..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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] sound: pci: ymfpci: ymfpci_main:- Handle return NULL error from ioremap_nocache
  2017-01-23  7:10 [PATCH v1] sound: pci: ymfpci: ymfpci_main:- Handle return NULL error from ioremap_nocache Arvind Yadav
@ 2017-01-23  7:24 ` Julia Lawall
  2017-01-23  7:37   ` Arvind Yadav
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2017-01-23  7:24 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: perex, tiwai, alsa-devel, linux-kernel

Some comments on the patch header:

* No need to put v1 on a patch.  If you are asked to revise it, then you
can start with v2.

* sound: pci: ymfpci: ymfpci_main is not the proper subject line for this
file.  Do git log --oneline and see what others have done.

* There should not be a - after the final colon in the subject line.

* I'm not sure why I was included in this patch.  get_maintainers by
default gives the names of a lot of people.  For general cleanup patches
like this one, you can use the following options, that will just send the
patch to the maintainers, and not to everyone who has ever touched the
file:

scripts/get_maintainer.pl --nokeywords --nogit --nogit-fallback --norolestats

julia

On Mon, 23 Jan 2017, 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;
> +	}
>  	pci_set_master(pci);
>  	chip->src441_used = -1;
>
> --
> 1.9.1
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] sound: pci: ymfpci: ymfpci_main:- Handle return NULL error from ioremap_nocache
  2017-01-23  7:24 ` Julia Lawall
@ 2017-01-23  7:37   ` Arvind Yadav
  0 siblings, 0 replies; 3+ messages in thread
From: Arvind Yadav @ 2017-01-23  7:37 UTC (permalink / raw)
  To: Julia Lawall; +Cc: perex, tiwai, alsa-devel, linux-kernel

I will take care your comments.

Thanks
-Arvind

On Monday 23 January 2017 12:54 PM, Julia Lawall wrote:
> or general cleanup patches
> like this one, you can use the following options, that will just send the
> patch to the maintainers, and not to everyone who has ever touched the

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-23  7:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-23  7:10 [PATCH v1] sound: pci: ymfpci: ymfpci_main:- Handle return NULL error from ioremap_nocache Arvind Yadav
2017-01-23  7:24 ` Julia Lawall
2017-01-23  7:37   ` Arvind Yadav

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®