Skip to contentSkip to conversation

Staging: bcm2835-audio: fix an uninitialized return value

PATCH In review Dan Carpenter 2 participants 3 messages Feb 7, 2017

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

PATCH 1/1 Staging: bcm2835-audio: fix an uninitialized return value

"ret" isn't necessarily initialized on the success path.

drivers/staging/bcm2835-audio/bcm2835-vchiq.c +1 -0
index 9ac1f72a178e..b7922be4909c 100644
@@ -432,6 +432,7 @@ static int bcm2835_audio_open_connection(struct bcm2835_alsa_stream *alsa_stream
 	alsa_stream->instance = instance;
 
 	LOG_DBG(" success !\n");
+	ret = 0;
 err_free_mem:
 	LOG_DBG(" .. OUT\n");
 
#1 lore raw
Quoted 4 lines · Dan Carpenter

"ret" isn't necessarily initialized on the success path.

The patch seems correct, but do you have any idea why gcc-7 didn't warn about this?
I assume that you found it with smatch, and nobody else did.

Arnd

#2 lore raw
In reply to Dan Carpenter
Quoted 8 lines · Arnd Bergmann
Quoted 4 lines · Dan Carpenter

"ret" isn't necessarily initialized on the success path.

The patch seems correct, but do you have any idea why gcc-7 didn't warn about this?

Heh... I'm not a gcc dev. Checking for uninitialized variables is harder than I would have thought though..

Quoted 1 line

I assume that you found it with smatch, and nobody else did.

Yep. I'm getting close to releasing my uninitialized variable check.

I guess the one thing holding me back is that I still have tons of false positives caused by mismatches between "if (ret)" and "if (ret < 0)" where the function assumes that non-zero is an error but the caller assumes that errors are negative.

regards,
dan carpenter