Skip to contentSkip to conversation

move dereference after null check

PATCH In review Dan Carpenter 4 participants 5 messages Nov 16, 2009 – Nov 18, 2009

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

PATCH 1/1 move dereference after null check

The 'jack' variable was dereference before the NULL check so this patch moves the dereference later.

regards,
dan carpenter

sound/soc/soc-jack.c +2 -1
@@ -58,7 +58,7 @@
  */
 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
 {
-	struct snd_soc_codec *codec = jack->card->codec;
+	struct snd_soc_codec *codec;
 	struct snd_soc_jack_pin *pin;
 	int enable;
 	int oldstatus;
@@ -67,6 +67,7 @@
 		WARN_ON_ONCE(!jack);
 		return;
 	}
+	codec = jack->card->codec;
 
 	mutex_lock(&codec->mutex);
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Dan Carpenter

The 'jack' variable was dereference before the NULL check so this patch moves the dereference later.

regards,
dan carpenter

Quoted 20 lines
sound/soc/soc-jack.c +2 -1
@@ -58,7 +58,7 @@
  */
 void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
 {
-	struct snd_soc_codec *codec = jack->card->codec;
+	struct snd_soc_codec *codec;
 	struct snd_soc_jack_pin *pin;
 	int enable;
 	int oldstatus;
@@ -67,6 +67,7 @@
 		WARN_ON_ONCE(!jack);
 		return;
 	}
+	codec = jack->card->codec;
 
 	mutex_lock(&codec->mutex);
 
#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

The 'jack' variable was dereference before the NULL check so this patch moves the dereference later.

regards,
dan carpenter

This does not apply to the current ASoC code, it appears that someone else has already provided an equivalent change. When doing work like this it's normally best to work against -next to help avoid duplication such as this.

#3 lore raw

At Mon, 16 Nov 2009 16:11:24 +0000,

Quoted 8 lines · Mark Brown
Quoted 6 lines · Dan Carpenter

The 'jack' variable was dereference before the NULL check so this patch moves the dereference later.

regards,
dan carpenter

Quoted 6 lines
Quoted 1 line

This does not apply to the current ASoC code, it appears that someone else has already provided an equivalent change. When doing work like this it's normally best to work against -next to help avoid duplication such as this.

Yep. FYI, it's the commit below:

commit 4f066173fe8deb8874f41917e5d26ea2e0c46e3b
Author: Julia Lawall <[email protected]>
Date: Sat Oct 17 08:32:56 2009 +0200
ASoC: Move dereference after NULL test

thanks,

Takashi

#4 lore raw
In reply to Mark Brown

Sorry about that.

I wish I could but until I get broadband, or git gets a restartable clone I can't use it for kernel development. The kernel archive is too big to download in one shot.

Right now I pay $20 and I can use wifi for a week but it's capped out at 200MB. Fortunately, I'm likely to get broadband soon. I'll pay $156 per month and it's capped at 200MB during business hours and "unlimitted" on nights and weekends. Woohoo!

regards,
dan carpenter

Quoted 14 lines · Mark Brown
Quoted 7 lines · Dan Carpenter

The 'jack' variable was dereference before the NULL check so this patch moves the dereference later.

regards,
dan carpenter

This does not apply to the current ASoC code, it appears that someone else has already provided an equivalent change. When doing work like this it's normally best to work against -next to help avoid duplication such as this.