From: Colin King <colin.king@canonical.com>
To: Vaibhav Agarwal <vaibhav.sr@gmail.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] greybus: audio: ensure module is set to avoid crash on dev_err message
Date: Fri, 23 Sep 2016 11:25:40 +0100 [thread overview]
Message-ID: <20160923102540.18261-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Currently, if info is null, the dev_err message is dereferencing an
uninitialized module pointer. Instead, initialize module before the
dev_err call to fix this issue.
Found using static analysis with cppcheck:
[drivers/staging/greybus/audio_topology.c:175]: (error)
Uninitialized variable: module
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/greybus/audio_topology.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 5eef536..c43a959 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -171,6 +171,9 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
data = (struct gbaudio_ctl_pvt *)kcontrol->private_value;
info = (struct gb_audio_ctl_elem_info *)data->info;
+ module = find_gb_module(gbcodec, kcontrol->id.name);
+ if (!module)
+ return -EINVAL;
if (!info) {
dev_err(module->dev, "NULL info for %s\n", uinfo->id.name);
return -EINVAL;
@@ -192,9 +195,6 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol,
uinfo->value.enumerated.items = max;
if (uinfo->value.enumerated.item > max - 1)
uinfo->value.enumerated.item = max - 1;
- module = find_gb_module(gbcodec, kcontrol->id.name);
- if (!module)
- return -EINVAL;
name = gbaudio_map_controlid(module, data->ctl_id,
uinfo->value.enumerated.item);
strlcpy(uinfo->value.enumerated.name, name, NAME_SIZE);
--
2.9.3
next reply other threads:[~2016-09-23 10:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 10:25 Colin King [this message]
2016-09-23 16:58 ` Greg Kroah-Hartman
2016-09-23 18:20 ` Vaibhav Agarwal
2016-09-23 18:29 ` Colin Ian King
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=20160923102540.18261-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=devel@driverdev.osuosl.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vaibhav.sr@gmail.com \
/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®