Staging: bcm2835-audio: fix an uninitialized return value
Subsystems (4)
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
@@ -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" );
Quoted 4 lines · Dan Carpenter
"ret" isn't necessarily initialized on the success path.
Signed-off-by Dan Carpenter <[email protected]>
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
Quoted 8 lines · Arnd Bergmann
Quoted 4 lines · Dan Carpenter
"ret" isn't necessarily initialized on the success path.
Signed-off-by Dan Carpenter <[email protected]>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