Skip to contentSkip to conversation

staging: fix possible use-before-NULL-check crash

PATCH In review Kees Cook 2 participants 3 messages Oct 6, 2010 – Oct 7, 2010 Staging

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 staging: fix possible use-before-NULL-check crash

Found via http://coccinelle.lip6.fr/rules/mini_null_ref.cocci

---
 drivers/staging/tm6000/tm6000-alsa.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/tm6000/tm6000-alsa.c +2 -1
index 087137d..c1aff0e 100644
@@ -426,10 +426,11 @@ error:
 
 static int tm6000_audio_fini(struct tm6000_core *dev)
 {
-	struct snd_tm6000_card	*chip = dev->adev;
+	struct snd_tm6000_card	*chip;
 
 	if (!dev)
 		return 0;
+	chip = dev->adev;
 
 	if (!chip)
 		return 0;
Signature · 6 lines
1.7.1


-- 
Kees Cook
Ubuntu Security Team
#1 lore raw
Quoted 12 lines · Kees Cook

Found via http://coccinelle.lip6.fr/rules/mini_null_ref.cocci

---
 drivers/staging/tm6000/tm6000-alsa.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/tm6000/tm6000-alsa.c +0 -0
index 087137d..c1aff0e 100644

drivers/staging/tm6000/tm6000-alsa.c error: · line 433

Quoted 9 lines
drivers/staging/tm6000/tm6000-alsa.c +2 -1
@@ -426,10 +426,11 @@ error:
 
 static int tm6000_audio_fini(struct tm6000_core *dev)
 {
-	struct snd_tm6000_card	*chip = dev->adev;
+	struct snd_tm6000_card	*chip;
 
 	if (!dev)
 		return 0;
+	chip = dev->adev;

Nice catch, but I don't think that the dev pointer can ever be NULL here.

Mauro, can you queue this up through your tree, as you handle this one?

thanks,

greg k-h

author
#2 lore raw

Hi Greg,

Quoted 2 lines · Greg KH

Nice catch, but I don't think that the dev pointer can ever be NULL here.

Yeah, I didn't think so either, but figured it was best to fix it anyway.

-Kees

Signature · 2 lines
Kees Cook
Ubuntu Security Team