Skip to contentSkip to conversation

sound/pci/hda/patch_ca0132.c: potential null dereference 'dma_engine'

DISCUSSION Fengguang Wu 4 participants 5 messages Sep 21, 2012 – Sep 27, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi Ian,

FYI, there are new smatch warnings show up in

commit 0b37d4c7982442730061a737c16939e8cc363861

Author:     Ian Minett <[email protected]>
Commit:     Takashi Iwai <[email protected]>
CommitDate: Fri Sep 21 09:54:29 2012 +0200

+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: potential null dereference 'dma_engine'. (kzalloc returns null)
+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: we previously assumed 'dma_engine' could be null (see line 1963)

---
0-DAY kernel build testing backend Open Source Technology Centre
Fengguang Wu, Yuanhan Liu Intel Corporation

#1 lore raw

At Fri, 21 Sep 2012 18:22:42 +0800,

Quoted 5 lines · Fengguang Wu

Hi Ian,

FYI, there are new smatch warnings show up in

Quoted 7 lines

commit 0b37d4c7982442730061a737c16939e8cc363861

Author:     Ian Minett <[email protected]>
Commit:     Takashi Iwai <[email protected]>
CommitDate: Fri Sep 21 09:54:29 2012 +0200

+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: potential null dereference 'dma_engine'. (kzalloc returns null)
+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: we previously assumed 'dma_engine' could be null (see line 1963)

Fixed with the patch below. Thanks!

Takashi

=Subject: [PATCH] ALSA: hda - Fix NULL dereference in error path of patch_ca0132.c

---
 sound/pci/hda/patch_ca0132.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/pci/hda/patch_ca0132.c +2 -4
index 5c6a056..03f57c9 100644
@@ -1960,10 +1960,8 @@ static int dspxfr_image(struct hda_codec *codec,
 		return -EINVAL;
 
 	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
-	if (!dma_engine) {
-		status = -ENOMEM;
-		goto exit;
-	}
+	if (!dma_engine)
+		return -ENOMEM;
 	memset((void *)dma_engine, 0, sizeof(*dma_engine));
 
 	dma_engine->dmab = kzalloc(sizeof(*dma_engine->dmab), GFP_KERNEL);
Signature · 1 line
1.7.11.5
#2 lore raw
Quoted 7 lines

FYI, there are new smatch warnings show up in
+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: potential null dereference 'dma_engine'.

(kzalloc returns null)

Quoted 1 line

+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: we previously assumed 'dma_engine' could

be null (see line 1963)

Thank you for catching these warnings, and to Takashi for patching them! It's greatly appreciated.

- Ian

#3 lore raw
In reply to Fengguang Wu

Am 21.09.2012 13:46, schrieb Takashi Iwai:

Quoted 33 lines

At Fri, 21 Sep 2012 18:22:42 +0800,

Quoted 5 lines · Fengguang Wu

Hi Ian,

FYI, there are new smatch warnings show up in

Quoted 7 lines

commit 0b37d4c7982442730061a737c16939e8cc363861

Author:     Ian Minett <[email protected]>
Commit:     Takashi Iwai <[email protected]>
CommitDate: Fri Sep 21 09:54:29 2012 +0200

+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: potential null dereference 'dma_engine'. (kzalloc returns null)
+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: we previously assumed 'dma_engine' could be null (see line 1963)

Fixed with the patch below. Thanks!

Takashi

=> Subject: [PATCH] ALSA: hda - Fix NULL dereference in error path of patch_ca0132.c

---
 sound/pci/hda/patch_ca0132.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/pci/hda/patch_ca0132.c +0 -0
index 5c6a056..03f57c9 100644
@@ -1960,10 +1960,8 @@ static int dspxfr_image(struct hda_codec *codec,
 		return -EINVAL;

sound/pci/hda/patch_ca0132.c static int dspxfr_image(struct hda_codec *codec, · line 1966

Quoted 10 lines
sound/pci/hda/patch_ca0132.c +2 -4
 
 	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
-	if (!dma_engine) {
-		status = -ENOMEM;
-		goto exit;
-	}
+	if (!dma_engine)
+		return -ENOMEM;
 	memset((void *)dma_engine, 0, sizeof(*dma_engine));
 

Why do you need that memset() ? kzalloc() should fill the buffer with 0.

re,
wh

Quoted 1 line
sound/pci/hda/patch_ca0132.c +0 -0
 	dma_engine->dmab = kzalloc(sizeof(*dma_engine->dmab), GFP_KERNEL);
#4 lore raw

At Fri, 21 Sep 2012 13:47:54 +0200,

Quoted 39 lines · walter harms

Am 21.09.2012 13:46, schrieb Takashi Iwai:

Quoted 35 lines

At Fri, 21 Sep 2012 18:22:42 +0800,

Quoted 5 lines · Fengguang Wu

Hi Ian,

FYI, there are new smatch warnings show up in

Quoted 7 lines

commit 0b37d4c7982442730061a737c16939e8cc363861

Author:     Ian Minett <[email protected]>
Commit:     Takashi Iwai <[email protected]>
CommitDate: Fri Sep 21 09:54:29 2012 +0200

+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: potential null dereference 'dma_engine'. (kzalloc returns null)
+ sound/pci/hda/patch_ca0132.c:2056 dspxfr_image() error: we previously assumed 'dma_engine' could be null (see line 1963)

Fixed with the patch below. Thanks!

Takashi

===
Subject: [PATCH] ALSA: hda - Fix NULL dereference in error path of patch_ca0132.c

---
 sound/pci/hda/patch_ca0132.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
sound/pci/hda/patch_ca0132.c +0 -0
index 5c6a056..03f57c9 100644
@@ -1960,10 +1960,8 @@ static int dspxfr_image(struct hda_codec *codec,
 		return -EINVAL;
 
Quoted 11 lines

sound/pci/hda/patch_ca0132.c static int dspxfr_image(struct hda_codec *codec, · line 1966

Quoted 9 lines
sound/pci/hda/patch_ca0132.c +2 -4
 	dma_engine = kzalloc(sizeof(*dma_engine), GFP_KERNEL);
-	if (!dma_engine) {
-		status = -ENOMEM;
-		goto exit;
-	}
+	if (!dma_engine)
+		return -ENOMEM;
 	memset((void *)dma_engine, 0, sizeof(*dma_engine));
 

Why do you need that memset() ? kzalloc() should fill the buffer with 0.

True.

Takashi