* [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list
@ 2017-03-01 17:11 jeeja.kp
2017-03-01 17:11 ` [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove jeeja.kp
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: jeeja.kp @ 2017-03-01 17:11 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, patches.audio, broonie, liam.r.girdwood, Jeeja KP
From: Jeeja KP <jeeja.kp@intel.com>
Using pin list array iterator outside the iteration of the list can
point to dummy element, which can be invalid. So don't use pin variable
outside the pin list iteration.
This fixes the following coccinelle warning:
sound/soc/codecs/hdac_hdmi.c:1419:5-8: ERROR: invalid reference to the
index variable of the iterator
Fixes: 2acd8309a3a4('ASoC: hdac_hdmi: Add support to handle MST capable pin')
Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
---
sound/soc/codecs/hdac_hdmi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 78fca8a..bb40569 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1534,21 +1534,20 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
pin->mst_capable = false;
/* if not MST, default is port[0] */
hport = &pin->ports[0];
- goto out;
} else {
for (i = 0; i < pin->num_ports; i++) {
pin->mst_capable = true;
if (pin->ports[i].id == pipe) {
hport = &pin->ports[i];
- goto out;
+ break;
}
}
}
+
+ if (hport)
+ hdac_hdmi_present_sense(pin, hport);
}
-out:
- if (pin && hport)
- hdac_hdmi_present_sense(pin, hport);
}
static struct i915_audio_component_audio_ops aops = {
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove
2017-03-01 17:11 [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list jeeja.kp
@ 2017-03-01 17:11 ` jeeja.kp
2017-03-06 10:46 ` Applied "ASoC: hdac_hdmi: don't update the iterator in pcm list remove" to the asoc tree Mark Brown
2017-03-02 8:52 ` [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list Vinod Koul
2017-03-06 10:46 ` Applied "ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list" to the asoc tree Mark Brown
2 siblings, 1 reply; 5+ messages in thread
From: jeeja.kp @ 2017-03-01 17:11 UTC (permalink / raw)
To: alsa-devel; +Cc: tiwai, patches.audio, broonie, liam.r.girdwood, Jeeja KP
From: Jeeja KP <jeeja.kp@intel.com>
Fix not to update the iterator element, instead use list_del to remove
entry from the list.
This fixes the following coccinelle and static checker warning:
sound/soc/codecs/hdac_hdmi.c:1884:2-21:iterator with update on line
1885
sound/soc/codecs/hdac_hdmi.c:2011 hdac_hdmi_dev_remove()
error: potential NULL dereference 'port'.
Fixes: e0e5d3e5a53b('ASoC: hdac_hdmi: Add support for multiple ports to a PCM')
Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
---
sound/soc/codecs/hdac_hdmi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index bb40569..fd272a4 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1997,7 +1997,7 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
struct hdac_hdmi_pin *pin, *pin_next;
struct hdac_hdmi_cvt *cvt, *cvt_next;
struct hdac_hdmi_pcm *pcm, *pcm_next;
- struct hdac_hdmi_port *port;
+ struct hdac_hdmi_port *port, *port_next;
int i;
snd_soc_unregister_codec(&edev->hdac.dev);
@@ -2007,8 +2007,9 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
if (list_empty(&pcm->port_list))
continue;
- list_for_each_entry(port, &pcm->port_list, head)
- port = NULL;
+ list_for_each_entry_safe(port, port_next,
+ &pcm->port_list, head)
+ list_del(&port->head);
list_del(&pcm->head);
kfree(pcm);
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list
2017-03-01 17:11 [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list jeeja.kp
2017-03-01 17:11 ` [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove jeeja.kp
@ 2017-03-02 8:52 ` Vinod Koul
2017-03-06 10:46 ` Applied "ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list" to the asoc tree Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2017-03-02 8:52 UTC (permalink / raw)
To: jeeja.kp; +Cc: tiwai, patches.audio, alsa-devel, broonie, liam.r.girdwood
On Wed, Mar 01, 2017 at 10:41:23PM +0530, jeeja.kp@intel.com wrote:
> From: Jeeja KP <jeeja.kp@intel.com>
>
> Using pin list array iterator outside the iteration of the list can
> point to dummy element, which can be invalid. So don't use pin variable
> outside the pin list iteration.
>
> This fixes the following coccinelle warning:
> sound/soc/codecs/hdac_hdmi.c:1419:5-8: ERROR: invalid reference to the
> index variable of the iterator
>
> Fixes: 2acd8309a3a4('ASoC: hdac_hdmi: Add support to handle MST capable pin')
> Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
> Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Both:
Acked-by: Vinod Koul <vinod.koul@intel.com>
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
* Applied "ASoC: hdac_hdmi: don't update the iterator in pcm list remove" to the asoc tree
2017-03-01 17:11 ` [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove jeeja.kp
@ 2017-03-06 10:46 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-03-06 10:46 UTC (permalink / raw)
To: Jeeja KP
Cc: alsa-devel, liam.r.girdwood, Vinod Koul, patches.audio,
Julia Lawall, broonie, tiwai, Dan Carpenter
The patch
ASoC: hdac_hdmi: don't update the iterator in pcm list remove
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 2fe42dd0f13812d38daaf05bcb1fd996afd0e87a Mon Sep 17 00:00:00 2001
From: Jeeja KP <jeeja.kp@intel.com>
Date: Wed, 1 Mar 2017 22:41:24 +0530
Subject: [PATCH] ASoC: hdac_hdmi: don't update the iterator in pcm list remove
Fix not to update the iterator element, instead use list_del to remove
entry from the list.
This fixes the following coccinelle and static checker warning:
sound/soc/codecs/hdac_hdmi.c:1884:2-21:iterator with update on line
1885
sound/soc/codecs/hdac_hdmi.c:2011 hdac_hdmi_dev_remove()
error: potential NULL dereference 'port'.
Fixes: e0e5d3e5a53b('ASoC: hdac_hdmi: Add support for multiple ports to a PCM')
Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/hdac_hdmi.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index bb405698e102..fd272a40485b 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1997,7 +1997,7 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
struct hdac_hdmi_pin *pin, *pin_next;
struct hdac_hdmi_cvt *cvt, *cvt_next;
struct hdac_hdmi_pcm *pcm, *pcm_next;
- struct hdac_hdmi_port *port;
+ struct hdac_hdmi_port *port, *port_next;
int i;
snd_soc_unregister_codec(&edev->hdac.dev);
@@ -2007,8 +2007,9 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
if (list_empty(&pcm->port_list))
continue;
- list_for_each_entry(port, &pcm->port_list, head)
- port = NULL;
+ list_for_each_entry_safe(port, port_next,
+ &pcm->port_list, head)
+ list_del(&port->head);
list_del(&pcm->head);
kfree(pcm);
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Applied "ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list" to the asoc tree
2017-03-01 17:11 [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list jeeja.kp
2017-03-01 17:11 ` [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove jeeja.kp
2017-03-02 8:52 ` [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list Vinod Koul
@ 2017-03-06 10:46 ` Mark Brown
2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-03-06 10:46 UTC (permalink / raw)
To: Jeeja KP
Cc: alsa-devel, liam.r.girdwood, Vinod Koul, patches.audio,
Julia Lawall, broonie, tiwai
The patch
ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 04c8f2bf9117de7b8e8bc0b90e8c4bff15f4f613 Mon Sep 17 00:00:00 2001
From: Jeeja KP <jeeja.kp@intel.com>
Date: Wed, 1 Mar 2017 22:41:23 +0530
Subject: [PATCH] ASoC: hdac_hdmi: avoid reference to invalid variable of the
pin list
Using pin list array iterator outside the iteration of the list can
point to dummy element, which can be invalid. So don't use pin variable
outside the pin list iteration.
This fixes the following coccinelle warning:
sound/soc/codecs/hdac_hdmi.c:1419:5-8: ERROR: invalid reference to the
index variable of the iterator
Fixes: 2acd8309a3a4('ASoC: hdac_hdmi: Add support to handle MST capable pin')
Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/codecs/hdac_hdmi.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 78fca8acd3ec..bb405698e102 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1534,21 +1534,20 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe)
pin->mst_capable = false;
/* if not MST, default is port[0] */
hport = &pin->ports[0];
- goto out;
} else {
for (i = 0; i < pin->num_ports; i++) {
pin->mst_capable = true;
if (pin->ports[i].id == pipe) {
hport = &pin->ports[i];
- goto out;
+ break;
}
}
}
+
+ if (hport)
+ hdac_hdmi_present_sense(pin, hport);
}
-out:
- if (pin && hport)
- hdac_hdmi_present_sense(pin, hport);
}
static struct i915_audio_component_audio_ops aops = {
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-06 10:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-01 17:11 [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list jeeja.kp
2017-03-01 17:11 ` [PATCH 2/2] ASoC: hdac_hdmi: don't update the iterator in pcm list remove jeeja.kp
2017-03-06 10:46 ` Applied "ASoC: hdac_hdmi: don't update the iterator in pcm list remove" to the asoc tree Mark Brown
2017-03-02 8:52 ` [PATCH 1/2] ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list Vinod Koul
2017-03-06 10:46 ` Applied "ASoC: hdac_hdmi: avoid reference to invalid variable of the pin list" to the asoc tree Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).