[alsa-devel] [PATCH] coverity fix in alsa-libs

Renu Tyagi renu.tyagi at samsung.com
Thu Sep 18 13:21:19 CEST 2014


Hi
Bug type : return negative value in case of error
I caught this error while running coverity on a older version. coverity will not give issue with latest version
But As per my analysis negative error should be returned in these cases, for debugging later on.
File changed : conf.c, control.c , pcm.c
PFA patch
-------------------------------------------------------------------------------------------
From d545d1ebedfbc42041e163536fbe2a6bd43361a0 Mon Sep 17 00:00:00 2001
From: renu tyagi <renu.tyagi at samsung.com>
Date: Thu, 18 Sep 2014 16:22:31 +0530
Subject: [PATCH 3/8] [conf, control, pcm] return negative value in case of error


Signed-off-by: renu tyagi <renu.tyagi at samsung.com>
---
 src/conf.c            |    1 +
 src/control/control.c |    1 +
 src/pcm/pcm.c         |    1 +
 3 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/conf.c b/src/conf.c
index 5ccc8e1..bb256e7 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -4198,6 +4198,7 @@ static int _snd_config_evaluate(snd_config_t *src,
                        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) {
diff --git a/src/control/control.c b/src/control/control.c
index d66ed75..dd428a1 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -864,6 +864,7 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for CTL type %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 1399a5b..79359dc 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2143,6 +2143,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
        if (err >= 0) {
                if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
                        SNDERR("Invalid type for PCM type %s definition", str);
+                       err = -EINVAL;
                        goto _err;
                }
                snd_config_for_each(i, next, type_conf) {
--
1.7.1


 
Thanks
Renu Tyagi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch3.patch
Type: application/octet-stream
Size: 1763 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20140918/cc419387/attachment-0001.obj>


More information about the Alsa-devel mailing list