[alsa-devel] [PATCH 1/2] alsa-lib: fixed coverity reported issues under "USE_AFTER_FREE" checker.

sudarshan.bisht at nokia.com sudarshan.bisht at nokia.com
Thu May 5 15:05:30 CEST 2011


From: Sudarshan Bisht <sudarshan.bisht at nokia.com>

Coverity Static Analysis helps developers find hard-to-spot,
yet potentially crash-causing defects early in the development phase,
reducing the cost,time, and risk of software errors.

This patch has fixes for 1) a junk assignment and 2) memory freed at wrong location.

---
 src/control/control_hw.c |    1 +
 src/mixer/mixer.c        |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/control/control_hw.c b/src/control/control_hw.c
index cf258b4..16c4987 100644
--- a/src/control/control_hw.c
+++ b/src/control/control_hw.c
@@ -414,6 +414,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
 	if (err < 0) {
 		close(fd);
 		free(hw);
+		return err;
 	}
 	ctl->ops = &snd_ctl_hw_ops;
 	ctl->private_data = hw;
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index 85d843f..5e5789a 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -228,7 +228,6 @@ int snd_mixer_attach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
 		return -ENOMEM;
 	err = snd_hctl_nonblock(hctl, 1);
 	if (err < 0) {
-		snd_hctl_close(hctl);
 		free(slave);
 		return err;
 	}
-- 
1.7.0.4



More information about the Alsa-devel mailing list