diff mbox

[v2] ASoC: Add a sanity check before using dai driver name

Message ID 20170824033411.5788-1-jeffy.chen@rock-chips.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeffy Chen Aug. 24, 2017, 3:34 a.m. UTC
The dai driver's name is allowed to be NULL. So add a sanity check for
that.

Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Reported-by: Donglin Peng <dolinux.peng@gmail.com>
---

Changes in v2:
Keep the oringinal check style.

 sound/soc/soc-core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Donglin Peng Aug. 24, 2017, 3:46 a.m. UTC | #1
On Thu, Aug 24, 2017 at 11:34 AM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
>                 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;

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

>
>                         return dai;
Jeffy Chen Aug. 24, 2017, 4:44 a.m. UTC | #2
Hi Dong,

Thanks for noticing, will send new patch soon :)

On 08/24/2017 11:46 AM, Donglin Peng wrote:
> On Thu, Aug 24, 2017 at 11:34 AM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
>>                  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;
>
> 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..
>
>>
>>                          return dai;
>
>
>
kernel test robot Aug. 26, 2017, 2:13 p.m. UTC | #3
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, lrg@slimlogic.co.uk");
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 <kay.sievers@vrfy.org>
:::::: CC: Takashi Iwai <tiwai@suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Donglin Peng Aug. 26, 2017, 3:09 p.m. UTC | #4
Hi Mark,

On Sat, Aug 26, 2017 at 10:13 PM, kbuild test robot <lkp@intel.com> wrote:
> 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)
>        ^

It seems that the v3 patch should be applied other than v2.
Mark Brown Aug. 27, 2017, 12:19 p.m. UTC | #5
On Sat, Aug 26, 2017 at 11:09:49PM +0800, Donglin Peng wrote:

> 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.
Donglin Peng Aug. 27, 2017, 1:54 p.m. UTC | #6
Hi Jeffy,

On Sun, Aug 27, 2017 at 8:19 PM, Mark Brown <broonie@kernel.org> wrote:
> On Sat, Aug 26, 2017 at 11:09:49PM +0800, Donglin Peng wrote:
>
>> 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.
Mark Brown Aug. 27, 2017, 2:26 p.m. UTC | #7
On Sun, Aug 27, 2017 at 09:54:09PM +0800, Donglin Peng wrote:
> On Sun, Aug 27, 2017 at 8:19 PM, Mark Brown <broonie@kernel.org> wrote:

> > 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.
Jeffy Chen Aug. 27, 2017, 2:31 p.m. UTC | #8
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]dolinux.peng@gmail.com>写�:

   Hi Jeffy,

   On Sun, Aug 27, [3]2017 at 8:19 PM, Mark Brown <[4]broonie@kernel.org>
   wrote:

   > On Sat, Aug 26, [5]2017 at 11:09:49PM +0800, Donglin Peng wrote:

   >

   >> 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.

References

   1. tel:2017
   2. mailto:dolinux.peng@gmail.com
   3. tel:2017
   4. mailto:broonie@kernel.org
   5. tel:2017
Mark Brown Aug. 27, 2017, 2:34 p.m. UTC | #9
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...
Jeffy Chen Aug. 27, 2017, 10:21 p.m. UTC | #10
hi Mark,

On 08/27/2017 10:34 PM, Mark Brown wrote:
> 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 :)
Donglin Peng Aug. 28, 2017, 1:47 a.m. UTC | #11
On Sun, Aug 27, 2017 at 10:31 PM, Jeffy Chen <jeffy.chen@rock-chips.com> wrote:
> 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.
diff mbox

Patch

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index fc1bb2da3e2e..c38c8f844546 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;