* [bug report] ASoC: soc-core: add snd_soc_rtdcom_xxx()
@ 2017-09-11 7:44 Dan Carpenter
2017-09-11 8:22 ` Kuninori Morimoto
2017-09-11 8:32 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() Kuninori Morimoto
0 siblings, 2 replies; 9+ messages in thread
From: Dan Carpenter @ 2017-09-11 7:44 UTC (permalink / raw)
To: kuninori.morimoto.gx; +Cc: alsa-devel
Hello Kuninori Morimoto,
This is a semi-automatic email about new static checker warnings.
The patch a0ac44115223: "ASoC: soc-core: add snd_soc_rtdcom_xxx()"
from Aug 8, 2017, leads to the following Smatch complaint:
sound/soc/soc-core.c:644 soc_free_pcm_runtime()
error: we previously assumed 'rtd' could be null (see line 642)
sound/soc/soc-core.c
641 {
642 if (rtd && rtd->codec_dais)
^^^
Check for NULL.
643 kfree(rtd->codec_dais);
644 snd_soc_rtdcom_del_all(rtd);
^^^
The check adds a new unchecked dereference inside the function. It's
weird that we call INIT_LIST_HEAD(&rtd->component_list), btw. Don't we
need to free the elements in the list?
645 kfree(rtd);
646 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [bug report] ASoC: soc-core: add snd_soc_rtdcom_xxx()
2017-09-11 7:44 [bug report] ASoC: soc-core: add snd_soc_rtdcom_xxx() Dan Carpenter
@ 2017-09-11 8:22 ` Kuninori Morimoto
2017-09-11 8:32 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() Kuninori Morimoto
1 sibling, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-11 8:22 UTC (permalink / raw)
To: Dan Carpenter; +Cc: alsa-devel
Hi Dan
> sound/soc/soc-core.c:644 soc_free_pcm_runtime()
> error: we previously assumed 'rtd' could be null (see line 642)
>
> sound/soc/soc-core.c
> 641 {
> 642 if (rtd && rtd->codec_dais)
> ^^^
> Check for NULL.
>
> 643 kfree(rtd->codec_dais);
> 644 snd_soc_rtdcom_del_all(rtd);
> ^^^
> The check adds a new unchecked dereference inside the function. It's
> weird that we call INIT_LIST_HEAD(&rtd->component_list), btw. Don't we
> need to free the elements in the list?
Yes, indeed.
Thank you for your report.
I will fix it soon
Best regards
---
Kuninori Morimoto
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime()
2017-09-11 7:44 [bug report] ASoC: soc-core: add snd_soc_rtdcom_xxx() Dan Carpenter
2017-09-11 8:22 ` Kuninori Morimoto
@ 2017-09-11 8:32 ` Kuninori Morimoto
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings kbuild test robot
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() kbuild test robot
1 sibling, 2 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-11 8:32 UTC (permalink / raw)
To: Mark Brown, Dan Carpenter; +Cc: Linux-ALSA, Simon
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
static soc_free_pcm_runtime() is never called with rtd==NULL.
This patch removes unnecessary rtd == NULL check from
soc_free_pcm_runtime().
Otherwise it logically inconsistent.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
sound/soc/soc-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 19f6d07..ee29d7c 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -407,7 +407,7 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd)
{
- if (rtd && rtd->codec_dais)
+ if (rtd->codec_dais)
kfree(rtd->codec_dais);
snd_soc_rtdcom_del_all(rtd);
kfree(rtd);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime()
2017-09-11 8:32 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() Kuninori Morimoto
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings kbuild test robot
@ 2017-09-14 1:08 ` kbuild test robot
1 sibling, 0 replies; 9+ messages in thread
From: kbuild test robot @ 2017-09-14 1:08 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Simon, Linux-ALSA, Mark Brown, kbuild-all, Dan Carpenter
Hi Kuninori,
[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.13 next-20170913]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kuninori-Morimoto/ASoC-soc-core-remove-rtd-NULL-check-from-soc_free_pcm_runtime/20170914-072344
base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
coccinelle warnings: (new ones prefixed by >>)
>> sound/soc/soc-core.c:643:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings
2017-09-11 8:32 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() Kuninori Morimoto
@ 2017-09-14 1:08 ` kbuild test robot
2017-09-14 1:17 ` Kuninori Morimoto
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() kbuild test robot
1 sibling, 1 reply; 9+ messages in thread
From: kbuild test robot @ 2017-09-14 1:08 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Simon, Linux-ALSA, Mark Brown, kbuild-all, Dan Carpenter
sound/soc/soc-core.c:643:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
NULL check before some freeing functions is not needed.
Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.
Generated by: scripts/coccinelle/free/ifnullfree.cocci
Fixes: 7e74acb4fc31 ("ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime()")
CC: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
soc-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -639,8 +639,7 @@ static struct snd_soc_pcm_runtime *soc_n
static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd)
{
- if (rtd->codec_dais)
- kfree(rtd->codec_dais);
+ kfree(rtd->codec_dais);
snd_soc_rtdcom_del_all(rtd);
kfree(rtd);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings kbuild test robot
@ 2017-09-14 1:17 ` Kuninori Morimoto
0 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2017-09-14 1:17 UTC (permalink / raw)
To: kbuild test robot
Cc: Simon, Linux-ALSA, Mark Brown, kbuild-all, Dan Carpenter
Hi
> sound/soc/soc-core.c:643:2-7: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
>
> NULL check before some freeing functions is not needed.
>
> Based on checkpatch warning
> "kfree(NULL) is safe this check is probably not required"
> and kfreeaddr.cocci by Julia Lawall.
>
> Generated by: scripts/coccinelle/free/ifnullfree.cocci
>
> Fixes: 7e74acb4fc31 ("ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime()")
> CC: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings
2019-05-30 23:06 [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings Julia Lawall
@ 2019-06-03 17:58 ` Mark Brown
0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2019-06-03 17:58 UTC (permalink / raw)
To: Julia Lawall
Cc: Kuninori Morimoto, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
alsa-devel, linux-kernel, kbuild-all
[-- Attachment #1: Type: text/plain, Size: 341 bytes --]
On Thu, May 30, 2019 at 07:06:11PM -0400, Julia Lawall wrote:
> From: kbuild test robot <lkp@intel.com>
>
> sound/soc/soc-core.c:391:2-7: WARNING: NULL check before some freeing functions is not needed.
>
> NULL check before some freeing functions is not needed.
This doesn't apply against current code, please check and resend.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings
@ 2019-06-03 17:58 ` Mark Brown
0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2019-06-03 17:58 UTC (permalink / raw)
To: Julia Lawall
Cc: alsa-devel, Kuninori Morimoto, Liam Girdwood, linux-kernel,
Takashi Iwai, kbuild-all
[-- Attachment #1.1: Type: text/plain, Size: 341 bytes --]
On Thu, May 30, 2019 at 07:06:11PM -0400, Julia Lawall wrote:
> From: kbuild test robot <lkp@intel.com>
>
> sound/soc/soc-core.c:391:2-7: WARNING: NULL check before some freeing functions is not needed.
>
> NULL check before some freeing functions is not needed.
This doesn't apply against current code, please check and resend.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings
@ 2019-05-30 23:06 Julia Lawall
2019-06-03 17:58 ` Mark Brown
0 siblings, 1 reply; 9+ messages in thread
From: Julia Lawall @ 2019-05-30 23:06 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
alsa-devel, linux-kernel, kbuild-all
From: kbuild test robot <lkp@intel.com>
sound/soc/soc-core.c:391:2-7: WARNING: NULL check before some freeing functions is not needed.
NULL check before some freeing functions is not needed.
Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.
Generated by: scripts/coccinelle/free/ifnullfree.cocci
Fixes: 8e144273005d ("ASoC: soc-core: merge soc_new_pcm_runtime() and soc_rtd_init()")
Signed-off-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
---
tree: https://github.com/morimoto/linux fw-cleanup-2019-05-30-v3
head: 7f2c61a9097fcf25dac44865db31e7eab5c8fc9d
commit: 8e144273005d3caf8b9978e407e3d00b6180dd49 [96/103] ASoC: soc-core: merge soc_new_pcm_runtime() and soc_rtd_init()
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
Please take the patch only if it's a positive warning. Thanks!
soc-core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -387,8 +387,7 @@ static void soc_free_pcm_runtime(struct
snd_soc_rtdcom_del_all(rtd);
- if (rtd->codec_dais)
- kfree(rtd->codec_dais);
+ kfree(rtd->codec_dais);
list_del(&rtd->list);
kfree(rtd);
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-06-03 17:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-11 7:44 [bug report] ASoC: soc-core: add snd_soc_rtdcom_xxx() Dan Carpenter
2017-09-11 8:22 ` Kuninori Morimoto
2017-09-11 8:32 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() Kuninori Morimoto
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings kbuild test robot
2017-09-14 1:17 ` Kuninori Morimoto
2017-09-14 1:08 ` [PATCH] ASoC: soc-core: remove rtd NULL check from soc_free_pcm_runtime() kbuild test robot
2019-05-30 23:06 [PATCH] ASoC: soc-core: fix ifnullfree.cocci warnings Julia Lawall
2019-06-03 17:58 ` Mark Brown
2019-06-03 17:58 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.