mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vaibhav Agarwal <vaibhav.sr@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Alex Elder <elder@linaro.org>, Johan Hovold <johan@kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Colin King <colin.king@canonical.com>,
	<devel@driverdev.osuosl.org>,
	Vaibhav Agarwal <vaibhav.sr@gmail.com>
Subject: [PATCH] greybus: audio: fix uninitialized variable errors found by cppcheck
Date: Sat, 24 Sep 2016 23:06:26 +0530	[thread overview]
Message-ID: <5eee4ae1a2a7717c8ec07a412eecad05730d5db5.1474737337.git.vaibhav.sr@gmail.com> (raw)

Currently, if info is null, the dev_err message is dereferencing an
uninitialized module pointer.  Instead, it should use codec->dev pointer
in dev_err call and better align with other err msg in this function.

Also, ret variable might be used uninitialized in a specific case.
Avoid using it this way.

Found using static analysis with cppcheck:
Checking drivers/staging/greybus/audio_topology.c...
[drivers/staging/greybus/audio_topology.c:175]: (error) Uninitialized
variable: module
[drivers/staging/greybus/audio_topology.c:495]: (error) Uninitialized
variable: ret

Reported-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
---
 drivers/staging/greybus/audio_topology.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index f9f33817a092..b6251691a33d 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -172,7 +172,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
 	info = (struct gb_audio_ctl_elem_info *)data->info;
 
 	if (!info) {
-		dev_err(module->dev, "NULL info for %s\n", uinfo->id.name);
+		dev_err(codec->dev, "NULL info for %s\n", uinfo->id.name);
 		return -EINVAL;
 	}
 
@@ -489,10 +489,11 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
 			dev_err_ratelimited(codec->dev,
 					    "%d:Error in %s for %s\n", ret,
 					    __func__, kcontrol->id.name);
+			return ret;
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 #define SOC_DAPM_MIXER_GB(xname, kcount, data) \
-- 
2.7.4

             reply	other threads:[~2016-09-24 17:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-24 17:36 Vaibhav Agarwal [this message]
2016-09-27  9:32 ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5eee4ae1a2a7717c8ec07a412eecad05730d5db5.1474737337.git.vaibhav.sr@gmail.com \
    --to=vaibhav.sr@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=elder@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®