]> git.alsa-project.org Git - alsa-lib.git/commitdiff
alsa-lib: fixed coverity reported issues under "FORWARD_NULL" checker.
authorSudarshan Bisht <sudarshan.bisht@nokia.com>
Tue, 12 Apr 2011 10:09:45 +0000 (13:09 +0300)
committerTakashi Iwai <tiwai@suse.de>
Wed, 4 May 2011 07:11:46 +0000 (09:11 +0200)
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 fix for situations where variable can be NULL
but not been checked beforehand

Signed-off-by: Takashi Iwai <tiwai@suse.de>
modules/mixer/simple/sbasedl.c
src/conf.c
src/hwdep/hwdep.c
src/pcm/pcm_hooks.c
src/pcm/pcm_simple.c
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_virt.c

index 0137586a520e542a8b2596553c53ade9b51adc54..494802f7469424202c1a6b37c5cb86a7ce17f5d6 100644 (file)
@@ -99,7 +99,7 @@ int mixer_simple_basic_dlopen(snd_mixer_class_t *class,
       __error:
        if (initflag)
                free(priv);
-       if (h == NULL)
+       if (h)
                snd_dlclose(h);
        free(xlib);
        return -ENXIO;
index 8939d62ec702482270dc8b1e12f0bb0d2a15a58f..ddefff6de66c008c8a8313392b1bc2f6fd863f2e 100644 (file)
@@ -3268,6 +3268,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
                snd_config_iterator_t i, next;
                if (snd_config_get_type(func_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for func %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, func_conf) {
index b882b35bc1c9b6e506f060a736a0a54eced1daa3..5dc791c9918970b2b6bb8ec8c16d1c691fa8c3c1 100644 (file)
@@ -78,6 +78,7 @@ static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for HWDEP type %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
index 3a99d55774208ad3da3e7559781ec39975070e26..404d51e783a21415be9df31c3a598409925f8c46 100644 (file)
@@ -385,6 +385,7 @@ static int snd_pcm_hook_add_conf(snd_pcm_t *pcm, snd_config_t *root, snd_config_
        if (err >= 0) {
                if (snd_config_get_type(type) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for PCM type %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, type) {
index 975f69987b2f6e8ab84ab520b25bf155c45e1e6a..f943ec09b396cbb023ee13de2a80e9331fe71d65 100644 (file)
@@ -89,7 +89,7 @@ static int set_hw_params(snd_pcm_t *pcm,
                        return err;
                if (periods == 1)
                        return -EINVAL;
-               if (*period_time == 0) {
+               if (period_time) {
                        err = INTERNAL(snd_pcm_hw_params_get_period_time)(hw_params, period_time, NULL);
                        if (err < 0)
                                return err;
index b28488a81fb8216bb2a1657f7ae077dd32e2453f..0bd6b9649f58dca79fa14c83bec8cf21b7e38b6e 100644 (file)
@@ -201,6 +201,7 @@ static int snd_rawmidi_open_conf(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for RAWMIDI type %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
index 52b89849baf68ed19d1706e672c178cc2329904f..e5b17e4861c42d98670851788cb0fecee7221b60 100644 (file)
@@ -383,9 +383,11 @@ int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
  _err:
        if (seq_handle)
                snd_seq_close(seq_handle);
-       if (virt->midi_event)
-               snd_midi_event_free(virt->midi_event);
-       free(virt);
+       if (virt) {
+               if (virt->midi_event)
+                       snd_midi_event_free(virt->midi_event);
+               free(virt);
+       }
        if (inputp)
                free(*inputp);
        if (outputp)