Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1489930

[PATCH] greybus: audio: ensure module is set to avoid crash on dev_err message

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] greybus: audio: ensure module is set to avoid crash on dev_err message
Date 2016-09-23 12:30 +0200
Message-ID <skvTY-2pQ-19@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View 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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] greybus: audio: ensure module is set to avoid crash on dev_err message Colin King <colin.king@canonical.com> - 2016-09-23 12:30 +0200
  Re: [PATCH] greybus: audio: ensure module is set to avoid crash on  dev_err message Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-09-23 19:00 +0200
    Re: [PATCH] greybus: audio: ensure module is set to avoid crash on  dev_err message Vaibhav Agarwal <vaibhav.sr@gmail.com> - 2016-09-23 20:30 +0200
      Re: [PATCH] greybus: audio: ensure module is set to avoid crash on  dev_err message Colin Ian King <colin.king@canonical.com> - 2016-09-23 20:30 +0200

csiph-web