Skip to contentSkip to conversation

usbusx2yaudio: kfree(NULL) is valid

PATCH In review Richard Knutsson 2 participants 2 messages May 12, 2007 – May 14, 2007 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usbusx2yaudio: kfree(NULL) is valid

if (!x) kfree(x); is not needed since kfree(NULL) is valid.

---
Compile-tested with all(yes|mod|no)config on x86(|_64) & sparc(|64) Diffed against Linus' git-tree.

sound/usb/usx2y/usbusx2yaudio.c +3 -4
index 0a352e4..48e9aa3 100644
@@ -935,10 +935,9 @@ static struct snd_pcm_ops snd_usX2Y_pcm_ops =
  */
 static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream)
 {
-	if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) {
-		kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
-		usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
-	}
+	kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
+	usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
+
 	kfree(usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]);
 	usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL;
 }
#1 lore raw

At Sat, 12 May 2007 20:29:20 +0200 (MEST),

Quoted 7 lines · Richard Knutsson

if (!x) kfree(x); is not needed since kfree(NULL) is valid.

---
Compile-tested with all(yes|mod|no)config on x86(|_64) & sparc(|64) Diffed against Linus' git-tree.

Thanks, merged to ALSA tree now.

Takashi

Quoted 21 lines
sound/usb/usx2y/usbusx2yaudio.c +3 -4
index 0a352e4..48e9aa3 100644
@@ -935,10 +935,9 @@ static struct snd_pcm_ops snd_usX2Y_pcm_ops =
  */
 static void usX2Y_audio_stream_free(struct snd_usX2Y_substream **usX2Y_substream)
 {
-	if (NULL != usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]) {
-		kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
-		usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
-	}
+	kfree(usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK]);
+	usX2Y_substream[SNDRV_PCM_STREAM_PLAYBACK] = NULL;
+
 	kfree(usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE]);
 	usX2Y_substream[SNDRV_PCM_STREAM_CAPTURE] = NULL;
 }