Skip to contentSkip to conversation

ASoC: Add a sanity check before using dai driver name

PATCH Superseded Jeffy Chen 4 participants 12 messages Aug 24, 2017 – Aug 28, 2017

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jeffy Chen

author
#0 lore raw

PATCH v2 1/1 ASoC: Add a sanity check before using dai driver name

The dai driver's name is allowed to be NULL. So add a sanity check for that.

---

Changes in v2:
Keep the oringinal check style.

 sound/soc/soc-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/soc-core.c +2 -1
index fc1bb2da3e2e..c38c8f844546 100644
@@ -1029,7 +1029,8 @@ struct snd_soc_dai *snd_soc_find_dai(
 			continue;
 		list_for_each_entry(dai, &component->dai_list, list) {
 			if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
-			    && strcmp(dai->driver->name, dlc->dai_name))
+			    && (!dai->driver->name
+				|| !strcmp(dai->driver->name, dlc->dai_name))
 				continue;
 
 			return dai;
Signature · 1 line
2.11.0
#1 lore raw

sound/soc/soc-core.c struct snd_soc_dai *snd_soc_find_dai( · line 1034

Quoted 6 lines · Jeffy Chen
                list_for_each_entry(dai, &component->dai_list, list) {
                        if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
sound/soc/soc-core.c +2 -1
-                           && strcmp(dai->driver->name, dlc->dai_name))
+                           && (!dai->driver->name
+                               || !strcmp(dai->driver->name, dlc->dai_name))
                                continue;

If the dai->driver->name is match with the dlc->dai_name, does it need to continue?

Quoted 2 lines
                        return dai;
author
#2 lore raw

Hi Dong,

Thanks for noticing, will send new patch soon :)

Quoted 10 lines · Donglin Peng

sound/soc/soc-core.c struct snd_soc_dai *snd_soc_find_dai( · line 1034

Quoted 6 lines · Jeffy Chen
                 list_for_each_entry(dai, &component->dai_list, list) {
                         if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
sound/soc/soc-core.c +2 -1
-                           && strcmp(dai->driver->name, dlc->dai_name))
+                           && (!dai->driver->name
+                               || !strcmp(dai->driver->name, dlc->dai_name))
                                 continue;

If the dai->driver->name is match with the dlc->dai_name, does it need to continue?

hmm, sorry, i did this in a hurry, should setup my board and test it..

Quoted 6 lines
Quoted 3 lines

                         return dai;
#3 lore raw
In reply to Jeffy Chen
reproduce:

Hi Jeffy,

[auto build test ERROR on asoc/for-next]
[also build test ERROR on next-20170825]
[cannot apply to v4.13-rc6]
[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/Jeffy-Chen/ASoC-Add-a-sanity-check-before-using-dai-driver-name/20170826-195851
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-it0-08261958 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

sound//soc/soc-core.c: In function 'snd_soc_find_dai':

>> sound//soc/soc-core.c:4321:0: error: unterminated argument list invoking macro "if"
    MODULE_ALIAS("platform:soc-audio");
    ^
>> sound//soc/soc-core.c:1031:4: error: expected '(' at end of input
       if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
       ^
>> sound//soc/soc-core.c:1031:4: error: expected declaration or statement at end of input
>> sound//soc/soc-core.c:1031:4: error: expected declaration or statement at end of input
>> sound//soc/soc-core.c:1031:4: error: expected declaration or statement at end of input
   In file included from include/uapi/linux/stddef.h:1:0,
                    from include/linux/stddef.h:4,
                    from include/uapi/linux/posix_types.h:4,
                    from include/uapi/linux/types.h:13,
                    from include/linux/types.h:5,
                    from include/linux/list.h:4,
                    from include/linux/module.h:9,
                    from sound//soc/soc-core.c:25:
   sound//soc/soc-core.c: At top level:
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcpy' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:390:2: note: in expansion of macro 'if'
     if (p_size == (size_t)-1 && q_size == (size_t)-1)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:380:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'kmemdup' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:378:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:369:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr_inv' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:367:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:358:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memchr' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:356:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:348:2: note: in expansion of macro 'if'
     if (p_size < size || q_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:345:3: note: in expansion of macro 'if'
      if (q_size < size)
      ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^

include/linux/string.h:343:3: note: in expansion of macro 'if'
if (p_size < size)
^
include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'memcmp' which is not static
--
include/linux/string.h:243:2: note: in expansion of macro 'if'

     if (p_size <= ret && maxlen != ret)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strlen' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:233:2: note: in expansion of macro 'if'
     if (p_size <= ret)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strlen' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:230:2: note: in expansion of macro 'if'
     if (p_size == (size_t)-1)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcat' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:221:2: note: in expansion of macro 'if'
     if (strlcat(p, q, p_size) >= p_size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strcat' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:219:2: note: in expansion of macro 'if'
     if (p_size == (size_t)-1)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strncpy' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:211:2: note: in expansion of macro 'if'
     if (p_size < size)
     ^
   include/linux/compiler.h:162:4: warning: '______f' is static but declared in inline function 'strncpy' which is not static
       ______f = {     \
       ^
   include/linux/compiler.h:154:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^
   include/linux/string.h:209:2: note: in expansion of macro 'if'
     if (__builtin_constant_p(size) && p_size < size)
     ^
   sound//soc/soc-core.c:229:38: warning: 'soc_dev_attr_groups' defined but not used [-Wunused-variable]
    static const struct attribute_group *soc_dev_attr_groups[] = {
                                         ^
   sound//soc/soc-core.c:301:13: warning: 'soc_init_component_debugfs' defined but not used [-Wunused-function]
    static void soc_init_component_debugfs(struct snd_soc_component *component)
                ^
   sound//soc/soc-core.c:334:13: warning: 'soc_cleanup_component_debugfs' defined but not used [-Wunused-function]
    static void soc_cleanup_component_debugfs(struct snd_soc_component *component)
                ^
   sound//soc/soc-core.c:339:13: warning: 'soc_init_codec_debugfs' defined but not used [-Wunused-function]
    static void soc_init_codec_debugfs(struct snd_soc_component *component)
                ^
   sound//soc/soc-core.c:468:13: warning: 'soc_init_card_debugfs' defined but not used [-Wunused-function]
    static void soc_init_card_debugfs(struct snd_soc_card *card)
                ^
   sound//soc/soc-core.c:489:13: warning: 'soc_cleanup_card_debugfs' defined but not used [-Wunused-function]
    static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
                ^
   sound//soc/soc-core.c:495:13: warning: 'snd_soc_debugfs_init' defined but not used [-Wunused-function]
    static void snd_soc_debugfs_init(void)
                ^
   sound//soc/soc-core.c:517:13: warning: 'snd_soc_debugfs_exit' defined but not used [-Wunused-function]
    static void snd_soc_debugfs_exit(void)
                ^
   sound//soc/soc-core.c:554:12: warning: 'snd_soc_rtdcom_add' defined but not used [-Wunused-function]
    static int snd_soc_rtdcom_add(struct snd_soc_pcm_runtime *rtd,
               ^
   sound//soc/soc-core.c:617:36: warning: 'soc_new_pcm_runtime' defined but not used [-Wunused-function]
    static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
                                       ^
   sound//soc/soc-core.c:648:13: warning: 'soc_add_pcm_runtime' defined but not used [-Wunused-function]
    static void soc_add_pcm_runtime(struct snd_soc_card *card,
                ^
   sound//soc/soc-core.c:656:13: warning: 'soc_remove_pcm_runtimes' defined but not used [-Wunused-function]
    static void soc_remove_pcm_runtimes(struct snd_soc_card *card)
                ^
   sound//soc/soc-core.c:682:13: warning: 'codec2codec_close_delayed_work' defined but not used [-Wunused-function]
    static void codec2codec_close_delayed_work(struct work_struct *work)
                ^
   sound//soc/soc-core.c:981:34: warning: 'soc_find_component' defined but not used [-Wunused-function]
    static struct snd_soc_component *soc_find_component(
                                     ^
   sound//soc/soc-core.c: In function 'snd_soc_find_dai':
>> sound//soc/soc-core.c:1031:4: warning: control reaches end of non-void function [-Wreturn-type]
       if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
       ^

vim +/if +4321 sound//soc/soc-core.c

db2a4165 Frank Mandarino 2006-10-06  4316  
db2a4165 Frank Mandarino 2006-10-06  4317  /* Module information */
d331124d Liam Girdwood   2008-10-12  4318  MODULE_AUTHOR("Liam Girdwood, [email protected]");
db2a4165 Frank Mandarino 2006-10-06  4319  MODULE_DESCRIPTION("ALSA SoC Core");
db2a4165 Frank Mandarino 2006-10-06  4320  MODULE_LICENSE("GPL");

8b45a209 Kay Sievers 2008-04-14 @4321 MODULE_ALIAS("platform:soc-audio");

:::::: The code at line 4321 was first introduced by commit
:::::: 8b45a209935c4b79905182608922736ba0e5579e [ALSA] sound: fix platform driver hotplug/coldplug

:::::: TO: Kay Sievers <[email protected]>
:::::: CC: Takashi Iwai <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

Hi Mark,

Quoted 17 lines · kbuild test robot

Hi Jeffy,

[auto build test ERROR on asoc/for-next]
[also build test ERROR on next-20170825]
[cannot apply to v4.13-rc6]
[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/Jeffy-Chen/ASoC-Add-a-sanity-check-before-using-dai-driver-name/20170826-195851
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-it0-08261958 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64

All error/warnings (new ones prefixed by >>):

Quoted 7 lines

sound//soc/soc-core.c: In function 'snd_soc_find_dai':

Quoted 1 line
Quoted 1 line

sound//soc/soc-core.c:4321:0: error: unterminated argument list invoking macro "if"

    MODULE_ALIAS("platform:soc-audio");
    ^
Quoted 1 line
Quoted 1 line

sound//soc/soc-core.c:1031:4: error: expected '(' at end of input

       if (dlc->dai_name && strcmp(dai->name, dlc->dai_name)
       ^

It seems that the v3 patch should be applied other than v2.

maintainer
#5 lore raw
Quoted 1 line · Donglin Peng

It seems that the v3 patch should be applied other than v2.

Please send incremental fixes rather than new versions for things that are are already applied.

#6 lore raw

Hi Jeffy,

Quoted 6 lines · Mark Brown
Quoted 1 line · Donglin Peng

It seems that the v3 patch should be applied other than v2.

Please send incremental fixes rather than new versions for things that are are already applied.

You should send a incremental patch rather than v3 patch, because your v2 patch had been applied and caused this issue.

maintainer
#7 lore raw
Quoted 7 lines · Donglin Peng
Quoted 2 lines · Mark Brown

Please send incremental fixes rather than new versions for things that are are already applied.

You should send a incremental patch rather than v3 patch, because your v2 patch had been applied and caused this issue.

Right, so I actually just looked at this and I think the right thing got applied as everything seems to be building fine but I could be confused here.

author
#8 lore raw
In reply to Donglin Peng

hi dong,

thanks for noticing, but i think mark've applied the right version.

this amazing robot would help to test all patches, not only the ones already applied :)

在 [1]2017å¹´8月27æ—¥ 下å�ˆ9:54,Donglin Peng <[2][email protected]>写é�“:

Hi Jeffy,

Quoted 9 lines · Mark Brown
Quoted 1 line · Donglin Peng

It seems that the v3 patch should be applied other than v2.

Please send incremental fixes rather than new versions for things

that

Quoted 1 line

are are already applied.

You should send a incremental patch rather than v3 patch, because your

v2 patch had been applied and caused this issue.

References

1. tel:2017
2. mailto:[email protected]
3. tel:2017
4. mailto:[email protected]
5. tel:2017
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#9 lore raw

On Sun, Aug 27, 2017 at 10:31:52PM +0800, Jeffy Chen wrote:

This is a HTML only mail and I have a text only client...

author
#10 lore raw

hi Mark,

Quoted 4 lines · Mark Brown

On Sun, Aug 27, 2017 at 10:31:52PM +0800, Jeffy Chen wrote:

This is a HTML only mail and I have a text only client...

sorry, i was replying with my phone, didn't notice it would use html by default...

i think you've applied the right version of patch(v3), and the robot is warning the v2 version :)

#11 lore raw
In reply to Jeffy Chen
Quoted 6 lines · Jeffy Chen

hi dong,

thanks for noticing, but i think mark've applied the right version.

this amazing robot would help to test all patches, not only the ones already applied :)

I also think so.