kasan: fix panic bug in check_channel_mask function
authortao zeng <tao.zeng@amlogic.com>
Fri, 7 Sep 2018 03:17:29 +0000 (11:17 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Fri, 7 Sep 2018 04:20:44 +0000 (21:20 -0700)
PD#172700

When open kasan, kernel paniced on P321:

Internal error: Oops: 96000005 [#1] PREEMPT SMP
PC is at strncmp+0x1e0/0x210
LR is at check_channel_mask+0x30/0xa8

[<ffffff900963ad10>] strncmp+0x1e0/0x210
[<ffffff9009e64418>] parse_speaker_channel_mask.isra.1+0x120/0x258
[<ffffff9009e6610c>] txl_chipset_init+0x8c/0xc0
[<ffffff9009e653ac>] aml_init_work_func+0x54/0x210
[<ffffff90090dcb18>] process_one_work+0x378/0x880
[<ffffff90090dd0bc>] worker_thread+0x9c/0x7a0
[<ffffff90090e6514>] kthread+0x184/0x1a0
[<ffffff9009083e80>] ret_from_fork+0x10/0x50

return value of of_property_read_string must be checked!

Change-Id: Ic0e0dcd0a3aa2f4ed10335e417f7db259a51fc95
Signed-off-by: tao zeng <tao.zeng@amlogic.com>
sound/soc/amlogic/meson/tv.c

index 4f3f08b..0401da8 100644 (file)
@@ -1529,36 +1529,44 @@ static void parse_speaker_channel_mask(struct snd_soc_card *card)
        }
 
        /* ext Speaker mask*/
-       of_property_read_string(np, "Speaker0_Channel_Mask", &str);
-       ret = check_channel_mask(str);
-       if (ret >= 0) {
-               p_aml_audio->Speaker0_Channel_Mask = ret;
-               aml_aiu_update_bits(AIU_I2S_OUT_CFG,
+       ret = of_property_read_string(np, "Speaker0_Channel_Mask", &str);
+       if (!ret) {
+               ret = check_channel_mask(str);
+               if (ret >= 0) {
+                       p_aml_audio->Speaker0_Channel_Mask = ret;
+                       aml_aiu_update_bits(AIU_I2S_OUT_CFG,
                                0x3, p_aml_audio->Speaker0_Channel_Mask);
+               }
        }
-       of_property_read_string(np, "Speaker1_Channel_Mask", &str);
-       ret = check_channel_mask(str);
-       if (ret >= 0) {
-               p_aml_audio->Speaker1_Channel_Mask = ret;
-               aml_aiu_update_bits(AIU_I2S_OUT_CFG,
+       ret = of_property_read_string(np, "Speaker1_Channel_Mask", &str);
+       if (!ret) {
+               ret = check_channel_mask(str);
+               if (ret >= 0) {
+                       p_aml_audio->Speaker1_Channel_Mask = ret;
+                       aml_aiu_update_bits(AIU_I2S_OUT_CFG,
                                0x3 << 2,
                                p_aml_audio->Speaker1_Channel_Mask << 2);
+               }
        }
-       of_property_read_string(np, "Speaker2_Channel_Mask", &str);
-       ret = check_channel_mask(str);
-       if (ret >= 0) {
-               p_aml_audio->Speaker2_Channel_Mask = ret;
-               aml_aiu_update_bits(AIU_I2S_OUT_CFG,
+       ret = of_property_read_string(np, "Speaker2_Channel_Mask", &str);
+       if (!ret) {
+               ret = check_channel_mask(str);
+               if (ret >= 0) {
+                       p_aml_audio->Speaker2_Channel_Mask = ret;
+                       aml_aiu_update_bits(AIU_I2S_OUT_CFG,
                                0x3 << 4,
                                p_aml_audio->Speaker2_Channel_Mask << 4);
+               }
        }
-       of_property_read_string(np, "Speaker3_Channel_Mask", &str);
-       ret = check_channel_mask(str);
-       if (ret >= 0) {
-               p_aml_audio->Speaker3_Channel_Mask = ret;
-               aml_aiu_update_bits(AIU_I2S_OUT_CFG,
+       ret = of_property_read_string(np, "Speaker3_Channel_Mask", &str);
+       if (!ret) {
+               ret = check_channel_mask(str);
+               if (ret >= 0) {
+                       p_aml_audio->Speaker3_Channel_Mask = ret;
+                       aml_aiu_update_bits(AIU_I2S_OUT_CFG,
                                0x3 << 6,
                                p_aml_audio->Speaker3_Channel_Mask << 6);
+               }
        }
 }