Skip to contentSkip to conversation

2.6.6 memory allocation checks in cs46xx_dsp_proc_register_scb_desc()

PATCH In review Yury Umanets 3 participants 4 messages Jun 6, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6.6 memory allocation checks in cs46xx_dsp_proc_register_scb_desc()

Adds memory allocation checks in cs46xx_dsp_proc_register_scb_desc()

 ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c |    3 +++
 1 files changed, 3 insertions(+)

diff -rupN ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c
--- ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c Mon May 10
05:33:20 2004
+++ ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c Wed Jun
2 14:57:41 2004
@@ -246,6 +246,9 @@ void cs46xx_dsp_proc_register_scb_desc (
if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
ins->proc_dsp_dir)) != NULL) {
scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL);
+ if (!scb_info)
+ return;
+
scb_info->chip = chip;
scb_info->scb_desc = scb;

Signature · 1 line
umka
#1 lore raw

On Sun, 06 Jun 2004 19:06:42 +0300 Yury Umanets wrote:

| Adds memory allocation checks in cs46xx_dsp_proc_register_scb_desc()
| 
|  ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c |    3 +++
|  1 files changed, 3 insertions(+)
| 
| diff -rupN ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c
| ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c
| --- ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c	Mon May 10
| 05:33:20 2004
| +++ ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c	Wed Jun 
| 2 14:57:41 2004
| @@ -246,6 +246,9 @@ void cs46xx_dsp_proc_register_scb_desc (
|  		if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
|  							ins->proc_dsp_dir)) != NULL) {
|  			scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL);
| +			if (!scb_info)
| +				return;
| +                                
|  			scb_info->chip = chip;
|  			scb_info->scb_desc = scb;
|        

This seems to be missing some other cleanup on the failure path, like it does below in the same function:

				snd_info_free_entry(entry);

--
~Randy

#2 lore raw
Quoted 24 lines · Randy.Dunlap

On Sun, 06 Jun 2004 19:06:42 +0300 Yury Umanets wrote:

| Adds memory allocation checks in cs46xx_dsp_proc_register_scb_desc()
| 
|  ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c |    3 +++
|  1 files changed, 3 insertions(+)
| 
| diff -rupN ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c
| ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c
| --- ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c	Mon May 10
| 05:33:20 2004
| +++ ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c	Wed Jun 
| 2 14:57:41 2004
| @@ -246,6 +246,9 @@ void cs46xx_dsp_proc_register_scb_desc (
|  		if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
|  							ins->proc_dsp_dir)) != NULL) {
|  			scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL);
| +			if (!scb_info)
| +				return;
| +                                
|  			scb_info->chip = chip;
|  			scb_info->scb_desc = scb;
|        
Quoted 4 lines

This seems to be missing some other cleanup on the failure path, like it does below in the same function:

				snd_info_free_entry(entry);

oops, you're right. Thanks Randy. Will fix that.

Quoted 8 lines

--
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 1 line
umka
#3 lore raw
Quoted 25 lines · Yury Umanets
Quoted 24 lines · Randy.Dunlap

On Sun, 06 Jun 2004 19:06:42 +0300 Yury Umanets wrote:

| Adds memory allocation checks in cs46xx_dsp_proc_register_scb_desc()
| 
|  ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c |    3 +++
|  1 files changed, 3 insertions(+)
| 
| diff -rupN ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c
| ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c
| --- ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c	Mon May 10
| 05:33:20 2004
| +++ ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c	Wed Jun 
| 2 14:57:41 2004
| @@ -246,6 +246,9 @@ void cs46xx_dsp_proc_register_scb_desc (
|  		if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
|  							ins->proc_dsp_dir)) != NULL) {
|  			scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL);
| +			if (!scb_info)
| +				return;
| +                                
|  			scb_info->chip = chip;
|  			scb_info->scb_desc = scb;
|        
Quoted 6 lines
Quoted 4 lines

This seems to be missing some other cleanup on the failure path, like it does below in the same function:

				snd_info_free_entry(entry);

oops, you're right. Thanks Randy. Will fix that.

Corrected version is bellow.

 ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c |    8
+++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)

diff -rupN ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c
--- ./linux-2.6.6/sound/pci/cs46xx/dsp_spos_scb_lib.c Mon May 10
05:33:20 2004
+++ ./linux-2.6.6-modified/sound/pci/cs46xx/dsp_spos_scb_lib.c Sun Jun
6 20:43:39 2004
@@ -246,6 +246,12 @@ void cs46xx_dsp_proc_register_scb_desc (
if ((entry = snd_info_create_card_entry(ins->snd_card, scb->scb_name,
ins->proc_dsp_dir)) != NULL) {
scb_info = kmalloc(sizeof(proc_scb_info_t), GFP_KERNEL);
+ if (!scb_info) {
+ snd_info_free_entry(entry);
+ entry = NULL;
+ goto out;
+ }
+
scb_info->chip = chip;
scb_info->scb_desc = scb;

@@ -262,7 +268,7 @@ void cs46xx_dsp_proc_register_scb_desc (
entry = NULL;
}
}
-
+out:
scb->proc_info = entry;
}
}

Signature · 1 line
umka