[PATCH] [UBUNTU:sound/isa/] Check kmalloc() return value

crimsun at fungus.sh.nu crimsun at fungus.sh.nu
Mon Oct 9 21:03:13 UTC 2006


From 96e24bc5c591f8bd4bb9ab19a82b71227c10d436 Mon Sep 17 00:00:00 2001
From: Daniel T. Chen <crimsun at garnish.localdomain>
Date: Mon, 9 Oct 2006 17:02:34 -0400
Subject: [PATCH] [UBUNTU:sound/isa/] Check kmalloc() return value

UpstreamStatus: Added in upstream alsa-kernel hg changesets:
		6d1bb3334f38 [http://hg-mirror.alsa-project.org/alsa-kernel?cmd=changeset;node=6d1bb3334f38daf3aae125dee8fab2628584f41a;style=raw]
		de1cd331d4b8 [http://hg-mirror.alsa-project.org/alsa-kernel?cmd=changeset;node=de1cd331d4b8553b4594e9d4efac39e3e69d0672;style=raw]
		6ba6c6b86ed3 [http://hg-mirror.alsa-project.org/alsa-kernel?cmd=changeset;node=6ba6c6b86ed33c28f62a8b9137d776d738e391d3;style=raw]
		56198a9ddbb6 [http://hg-mirror.alsa-project.org/alsa-kernel?cmd=changeset;node=56198a9ddbb619147c18ca0f0a36498b2a7cbaf3;style=raw]

This commit adds checks for kmalloc()'s return value to the following
drivers: opti9xx, interwave, cmi8330, and ad1816a.

This commit is applicable to both Dapper and Edgy linux-source.

Signed-off-by: Amit Choudhary <amit2030 at gmail.com>
Signed-off-by: Daniel T Chen <crimsun at ubuntu.com>
---
 sound/isa/ad1816a/ad1816a.c        |    2 ++
 sound/isa/cmi8330.c                |    2 ++
 sound/isa/gus/interwave.c          |    2 ++
 sound/isa/opti9xx/opti92x-ad1848.c |    2 ++
 4 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/sound/isa/ad1816a/ad1816a.c b/sound/isa/ad1816a/ad1816a.c
index 0eb442c..c1b2a0b 100644
--- a/sound/isa/ad1816a/ad1816a.c
+++ b/sound/isa/ad1816a/ad1816a.c
@@ -120,6 +120,8 @@ static int __devinit snd_card_ad1816a_pn
 	struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
 	int err;
 
+	if (!cfg)
+		return -ENOMEM;
 	acard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
 	if (acard->dev == NULL) {
 		kfree(cfg);
diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
index 5252206..c2bcb80 100644
--- a/sound/isa/cmi8330.c
+++ b/sound/isa/cmi8330.c
@@ -284,6 +284,8 @@ static int __devinit snd_cmi8330_pnp(int
 	struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
 	int err;
 
+	if (!cfg)
+		return -ENOMEM;
 	acard->cap = pnp_request_card_device(card, id->devs[0].id, NULL);
 	if (acard->cap == NULL) {
 		kfree(cfg);
diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c
index f703a9f..ce8b92c 100644
--- a/sound/isa/gus/interwave.c
+++ b/sound/isa/gus/interwave.c
@@ -557,6 +557,8 @@ static int __devinit snd_interwave_pnp(i
 	struct pnp_resource_table * cfg = kmalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
 	int err;
 
+	if (!cfg)
+		return -ENOMEM;
 	iwcard->dev = pnp_request_card_device(card, id->devs[0].id, NULL);
 	if (iwcard->dev == NULL) {
 		kfree(cfg);
diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index b94339f..e12aad8 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -1693,6 +1693,8 @@ static int __devinit snd_card_opti9xx_pn
 	struct pnp_resource_table *cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
 	int err;
 
+	if (!cfg)
+		return -ENOMEM;
 	chip->dev = pnp_request_card_device(card, pid->devs[0].id, NULL);
 	if (chip->dev == NULL) {
 		kfree(cfg);
-- 
1.4.1


-- 
Daniel T. Chen            crimsun at ubuntu.com
GPG key:  0xC88ABDA3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20061009/1129cce4/attachment.pgp>


More information about the kernel-team mailing list