ASoC: Intel: Skylake: Fix to use list_for_each_safe() when delete items
Subsystems (3)
PATCH 1/1 ASoC: Intel: Skylake: Fix to use list_for_each_safe() when delete items
From: Wei Yongjun <[email protected]>
Since we will remove items off the list using list_del() we need to use a safe version of the list_for_each() macro aptly named list_for_each_safe().
This is detected by Coccinelle semantic patch.
DSP module bind")
--- sound/soc/intel/skylake/skl-pcm.c | 4 ++-- sound/soc/intel/skylake/skl-topology.c | 4 ++-- 2 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +2 -2
@@ -1323,10 +1323,10 @@ int skl_platform_unregister(struct device *dev) {struct hdac_ext_bus *ebus =dev_get_drvdata (dev);struct skl *skl =ebus_to_skl (ebus); -struct skl_module_deferred_bind *modules; +struct skl_module_deferred_bind *modules, *tmp;if (!list_empty (&skl->bind_list)) { -list_for_each_entry (modules, &skl->bind_list, node) { +list_for_each_entry_safe (modules, tmp, &skl->bind_list, node) {list_del (&modules->node);kfree (modules); }
sound/soc/intel/skylake/skl-topology.c +2 -2
@@ -1091,7 +1091,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,struct skl_module_cfg *src_module =NULL , *dst_module;struct skl_sst *ctx = skl->skl_sst;struct skl_pipe *s_pipe = mconfig->pipe; -struct skl_module_deferred_bind *modules; +struct skl_module_deferred_bind *modules, *tmp;if (s_pipe->state ==SKL_PIPE_INVALID )return -EINVAL ;
@@ -1105,7 +1105,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, src_module = w_module->w->priv; -list_for_each_entry (modules, &skl->bind_list, node) { +list_for_each_entry_safe (modules, tmp, &skl->bind_list, node) {/* * When the destination module is deleted, Unbind the * modules from deferred bind list.
Quoted 5 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
Since we will remove items off the list using
list_del()we need to use a safe version of thelist_for_each()macro aptly namedlist_for_each_safe().
ah yes, god catch
Quoted 1 line
This is detected by Coccinelle semantic patch.
It is a good practice to include the script you used, do you mind adding that in the log?
Quoted 49 lines
Fixes b8c722ddd548 ("ASoC: Intel: Skylake: Add support for deferredDSP module bind")
Signed-off-by Wei Yongjun <[email protected]>--- sound/soc/intel/skylake/skl-pcm.c | 4 ++-- sound/soc/intel/skylake/skl-topology.c | 4 ++-- 2 file changed, 4 insertions(+), 4 deletions(-)sound/soc/intel/skylake/skl-pcm.c +2
-2@@ -1323,10 +1323,10 @@ int skl_platform_unregister(struct device *dev) {struct hdac_ext_bus *ebus =dev_get_drvdata (dev);struct skl *skl =ebus_to_skl (ebus); -struct skl_module_deferred_bind *modules; +struct skl_module_deferred_bind *modules, *tmp;if (!list_empty (&skl->bind_list)) { -list_for_each_entry (modules, &skl->bind_list, node) { +list_for_each_entry_safe (modules, tmp, &skl->bind_list, node) {list_del (&modules->node);kfree (modules); }sound/soc/intel/skylake/skl-topology.c +2
-2@@ -1091,7 +1091,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,struct skl_module_cfg *src_module =NULL , *dst_module;struct skl_sst *ctx = skl->skl_sst;struct skl_pipe *s_pipe = mconfig->pipe; -struct skl_module_deferred_bind *modules; +struct skl_module_deferred_bind *modules, *tmp;if (s_pipe->state ==SKL_PIPE_INVALID )return -EINVAL ;@@ -1105,7 +1105,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, src_module = w_module->w->priv; -list_for_each_entry (modules, &skl->bind_list, node) { +list_for_each_entry_safe (modules, tmp, &skl->bind_list, node) {/* * When the destination module is deleted, Unbind the * modules from deferred bind list.
Signature · 1 line
~Vinod
Quoted 24 lines
-----Original Message-----
From: Vinod Koul [mailto:[email protected]]
Sent: Tuesday, April 25, 2017 12:01 PM
To: Wei Yongjun <[email protected]>
Cc: Liam Girdwood <[email protected]>; Mark Brown <[email protected]>; Jaroslav Kysela <[email protected]>; Takashi Iwai <[email protected]>; Pardha Saradhi K <[email protected]>; G Kranthi <[email protected]>; Hardik T Shah <[email protected]>; Jeeja KP <[email protected]>; weiyongjun (A) <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH -next] ASoC: Intel: Skylake: Fix to uselist_for_each_safe()when delete itemsQuoted 5 lines · Wei Yongjun
From: Wei Yongjun <[email protected]>
Since we will remove items off the list using
list_del()we need to use a safe version of thelist_for_each()macro aptly namedlist_for_each_safe().
Quoted 7 lines
ah yes, god catch
Quoted 1 line
This is detected by Coccinelle semantic patch.
It is a good practice to include the script you used, do you mind adding that in the log?
Sure.
@@
iterator name list_for_each;
expression E;
expression pos, head;
identifier l;
@@
* list_for_each(pos, head)
{
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(pos, ...); ... when != \(goto l; \| break; \| return E; \| return;\) }
@@
expression E;
expression pos, head, ep;
identifier list;
identifier l;
@@
* list_for_each(pos, head)
{
...
* ep = list_entry(pos, ..., list);
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(&ep->list, ...); ... when != \(goto l; \| break; \| return E; \| return;\)
}
@@
iterator name list_for_each_prev;
expression E;
expression pos, head;
identifier l;
@@
* list_for_each_prev(pos, head)
{
...
* \(list_del\|list_del_init\)(pos);
... when != \(goto l; \| break; \| return E; \| return;\) }
@@
iterator name list_for_each_entry;
expression E;
expression pos, head;
identifier l, member;
@@
* list_for_each_entry(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }
@@
iterator name list_for_each_entry_from;
expression E;
expression pos, head;
identifier l, member;
@@
* list_for_each_entry_from(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }
@@
iterator name list_for_each_entry_reverse;
expression E;
expression pos, head;
identifier l, member;
@@
* list_for_each_entry_reverse(pos, head, member) {
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }
Quoted 7 lines · weiyongjun (A)
Quoted 7 lines
Quoted 4 lines
Since we will remove items off the list using
list_del()we need to use a safe version of thelist_for_each()macro aptly namedlist_for_each_safe().ah yes, god catch
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
This is detected by Coccinelle semantic patch.
It is a good practice to include the script you used, do you mind adding that in the log?
Sure.
Sorry I meant this should be in changelog of the patch :)
Quoted 83 lines
@@
iterator namelist_for_each;
expression E;
expression pos, head;
identifier l;
@@
*list_for_each(pos, head)
{
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(pos, ...); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
expression E;
expression pos, head, ep;
identifier list;
identifier l;
@@
*list_for_each(pos, head)
{
...
* ep =list_entry(pos, ..., list);
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(&ep->list, ...); ... when != \(goto l; \| break; \| return E; \| return;\)
}@@
iterator namelist_for_each_prev;
expression E;
expression pos, head;
identifier l;
@@
*list_for_each_prev(pos, head)
{
...
* \(list_del\|list_del_init\)(pos);
... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry;
expression E;
expression pos, head;
identifier l, member;
@@*
list_for_each_entry(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry_from;
expression E;
expression pos, head;
identifier l, member;
@@*
list_for_each_entry_from(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry_reverse;
expression E;
expression pos, head;
identifier l, member;
@@*
list_for_each_entry_reverse(pos, head, member){
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }
Signature · 1 line
~Vinod
Quoted 26 lines
-----Original Message-----
From: Vinod Koul [mailto:[email protected]]
Sent: Wednesday, April 26, 2017 1:38 PM
To: weiyongjun (A) <[email protected]>
Cc: Wei Yongjun <[email protected]>; Liam Girdwood <[email protected]>; Mark Brown <[email protected]>; Jaroslav Kysela <[email protected]>; Takashi Iwai <[email protected]>; Pardha Saradhi K <[email protected]>; G Kranthi <[email protected]>; Hardik T Shah <[email protected]>; Jeeja KP <[email protected]>; alsa- [email protected]; [email protected]
Subject: Re: [PATCH -next] ASoC: Intel: Skylake: Fix to uselist_for_each_safe()when delete itemsQuoted 9 lines · weiyongjun (A)
Quoted 9 lines
Quoted 4 lines
Since we will remove items off the list using
list_del()we need to use a safe version of thelist_for_each()macro aptly namedlist_for_each_safe().ah yes, god catch
Quoted 1 line
This is detected by Coccinelle semantic patch.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
It is a good practice to include the script you used, do you mind adding that in the log?
Sure.
Sorry I meant this should be in changelog of the patch :)
OK, I will add this and send the v2 version patch later.
Quoted 11 lines · weiyongjun (A)
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Since we will remove items off the list using
list_del()we need to use a safe version of thelist_for_each()macro aptly namedlist_for_each_safe().ah yes, god catch
Quoted 1 line
This is detected by Coccinelle semantic patch.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
It is a good practice to include the script you used, do you mind adding that in the log?
Sure.
Sorry I meant this should be in changelog of the patch :)
Oh, a similar patch has been applied. Please ignore this one.
Quoted 87 lines
Quoted 78 lines
@@
iterator namelist_for_each;
expression E;
expression pos, head;
identifier l;
@@
*list_for_each(pos, head)
{
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(pos, ...); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
expression E;
expression pos, head, ep;
identifier list;
identifier l;
@@
*list_for_each(pos, head)
{
...
* ep =list_entry(pos, ..., list);
...
* \(list_del\|list_del_init\|list_move\|list_move_tail\)(&ep->list, ...); ... when != \(goto l; \| break; \| return E; \| return;\)
}@@
iterator namelist_for_each_prev;
expression E;
expression pos, head;
identifier l;
@@
*list_for_each_prev(pos, head)
{
...
* \(list_del\|list_del_init\)(pos);
... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry;
expression E;
expression pos, head;
identifier l, member;
@@*
list_for_each_entry(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry_from;
expression E;
expression pos, head;
identifier l, member;
@@*
list_for_each_entry_from(pos, head, member)
{
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }@@
iterator namelist_for_each_entry_reverse;
expression E;
expression pos, head;
identifier l, member;
@@Quoted 6 lines
*
list_for_each_entry_reverse(pos, head, member){
...
* \(list_del\|list_del_init\)(&pos->member); ... when != \(goto l; \| break; \| return E; \| return;\) }--
~Vinod