summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiranjan H Y2022-01-05 00:17:38 -0600
committerNiranjan H Y2022-01-05 00:17:38 -0600
commit465b9efbac263faa072c81cdfe660454ceed99cf (patch)
treeb4d31dd09215d54e613570e0a21285122562a686
parent2757f4a1b67744b75af429fff00e03e814e044cb (diff)
downloadtas256x-stereo-driver-SAMSUMG_A72_4.19.tar.gz
tas256x-stereo-driver-SAMSUMG_A72_4.19.tar.xz
tas256x-stereo-driver-SAMSUMG_A72_4.19.zip
static code analysis issue fix - misc.c, codec.c and regmap.cSAMSUMG_A72_4.19
-rw-r--r--tas256x_driver/misc/tas256x-misc.c13
-rw-r--r--tas256x_driver/os_layer/src/tas256x-codec.c13
-rw-r--r--tas256x_driver/os_layer/src/tas256x-regmap.c13
3 files changed, 31 insertions, 8 deletions
diff --git a/tas256x_driver/misc/tas256x-misc.c b/tas256x_driver/misc/tas256x-misc.c
index dad5d0d..7ab0123 100644
--- a/tas256x_driver/misc/tas256x-misc.c
+++ b/tas256x_driver/misc/tas256x-misc.c
@@ -72,11 +72,15 @@ static ssize_t tas256x_file_read(struct file *file,
72 int ret = 0; 72 int ret = 0;
73 unsigned char *p_kbuf = NULL; 73 unsigned char *p_kbuf = NULL;
74 unsigned int reg = 0; 74 unsigned int reg = 0;
75 unsigned int len = 0; 75 size_t len = 0;
76 unsigned int channel = channel_left; 76 unsigned int channel = channel_left;
77 77
78 mutex_lock(&p_tas256x->file_lock); 78 mutex_lock(&p_tas256x->file_lock);
79 79
80 /* count should be atleast 6*/
81 if (count < 6)
82 goto err;
83
80 p_kbuf = kzalloc(count, GFP_KERNEL); 84 p_kbuf = kzalloc(count, GFP_KERNEL);
81 if (p_kbuf == NULL) 85 if (p_kbuf == NULL)
82 goto err; 86 goto err;
@@ -87,7 +91,7 @@ static ssize_t tas256x_file_read(struct file *file,
87 goto err; 91 goto err;
88 } 92 }
89 93
90 if ((p_kbuf[1] >= 0) && ((p_kbuf[1] <= 1))) 94 if (p_kbuf[1] <= 1)
91 channel = p_kbuf[1]+1; 95 channel = p_kbuf[1]+1;
92 96
93 switch (p_kbuf[0]) { 97 switch (p_kbuf[0]) {
@@ -146,7 +150,7 @@ static ssize_t tas256x_file_write(struct file *file,
146 int ret = 0; 150 int ret = 0;
147 unsigned char *p_kbuf = NULL; 151 unsigned char *p_kbuf = NULL;
148 unsigned int reg = 0; 152 unsigned int reg = 0;
149 unsigned int len = 0; 153 size_t len = 0;
150 unsigned int channel = channel_left; 154 unsigned int channel = channel_left;
151 155
152 mutex_lock(&p_tas256x->file_lock); 156 mutex_lock(&p_tas256x->file_lock);
@@ -161,8 +165,9 @@ static ssize_t tas256x_file_write(struct file *file,
161 goto err; 165 goto err;
162 } 166 }
163 167
164 if ((p_kbuf[1] >= 0) && ((p_kbuf[1] <= 1))) 168 if (p_kbuf[1] <= 1)
165 channel = p_kbuf[1]+1; 169 channel = p_kbuf[1]+1;
170
166 switch (p_kbuf[0]) { 171 switch (p_kbuf[0]) {
167 case TIAUDIO_CMD_REG_WITE: 172 case TIAUDIO_CMD_REG_WITE:
168 if (count > 5) { 173 if (count > 5) {
diff --git a/tas256x_driver/os_layer/src/tas256x-codec.c b/tas256x_driver/os_layer/src/tas256x-codec.c
index 7023975..2f7a538 100644
--- a/tas256x_driver/os_layer/src/tas256x-codec.c
+++ b/tas256x_driver/os_layer/src/tas256x-codec.c
@@ -404,6 +404,9 @@ static int tas256x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
404 ret = -EINVAL; 404 ret = -EINVAL;
405 } 405 }
406 406
407 if (ret)
408 goto end;
409
407 switch (fmt & SND_SOC_DAIFMT_INV_MASK) { 410 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
408 case SND_SOC_DAIFMT_NB_NF: 411 case SND_SOC_DAIFMT_NB_NF:
409 dev_info(plat_data->dev, "INV format: NBNF\n"); 412 dev_info(plat_data->dev, "INV format: NBNF\n");
@@ -430,6 +433,9 @@ static int tas256x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
430 ret = -EINVAL; 433 ret = -EINVAL;
431 } 434 }
432 435
436 if (ret)
437 goto end;
438
433 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 439 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
434 case (SND_SOC_DAIFMT_I2S): 440 case (SND_SOC_DAIFMT_I2S):
435 tdm_rx_start_slot = 1; 441 tdm_rx_start_slot = 1;
@@ -456,11 +462,14 @@ static int tas256x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
456 "SND_SOC_DAIFMT_LEFT_J tdm_rx_start_slot = 0\n"); 462 "SND_SOC_DAIFMT_LEFT_J tdm_rx_start_slot = 0\n");
457 break; 463 break;
458 default: 464 default:
459 dev_err(plat_data->dev, "DAI Format is not found, fmt=0x%x\n", fmt); 465 dev_err(plat_data->dev, "DAI Format is not found, fmt=0x%x\n", fmt);
460 ret = -EINVAL; 466 ret = -EINVAL;
461 break; 467 break;
462 } 468 }
463 469
470 if (ret)
471 goto end;
472
464 ret = tas256x_rx_set_start_slot(p_tas256x, 473 ret = tas256x_rx_set_start_slot(p_tas256x,
465 tdm_rx_start_slot, channel_both); 474 tdm_rx_start_slot, channel_both);
466 if (ret) 475 if (ret)
diff --git a/tas256x_driver/os_layer/src/tas256x-regmap.c b/tas256x_driver/os_layer/src/tas256x-regmap.c
index 61d63bd..e902147 100644
--- a/tas256x_driver/os_layer/src/tas256x-regmap.c
+++ b/tas256x_driver/os_layer/src/tas256x-regmap.c
@@ -1014,10 +1014,11 @@ static void irq_work_routine(struct work_struct *work)
1014 /*Logical Layer IRQ function, return is ignored*/ 1014 /*Logical Layer IRQ function, return is ignored*/
1015 tas256x_irq_work_func(p_tas256x); 1015 tas256x_irq_work_func(p_tas256x);
1016 1016
1017end:
1017#if IS_ENABLED(CONFIG_TAS256X_CODEC) 1018#if IS_ENABLED(CONFIG_TAS256X_CODEC)
1018 mutex_unlock(&p_tas256x->codec_lock); 1019 mutex_unlock(&p_tas256x->codec_lock);
1019#endif 1020#endif
1020end: 1021
1021 return; 1022 return;
1022} 1023}
1023 1024
@@ -1174,10 +1175,16 @@ static int tas256x_parse_dt(struct device *dev,
1174 p_tas256x->devs = 1175 p_tas256x->devs =
1175 kmalloc(p_tas256x->mn_channels * sizeof(struct tas_device *), 1176 kmalloc(p_tas256x->mn_channels * sizeof(struct tas_device *),
1176 GFP_KERNEL); 1177 GFP_KERNEL);
1178 if (!p_tas256x->devs) {
1179 rc = -1;
1180 goto EXIT;
1181 }
1182
1177 for (i = 0; i < p_tas256x->mn_channels; i++) { 1183 for (i = 0; i < p_tas256x->mn_channels; i++) {
1178 p_tas256x->devs[i] = kmalloc(sizeof(struct tas_device), 1184 p_tas256x->devs[i] = kmalloc(sizeof(struct tas_device),
1179 GFP_KERNEL); 1185 GFP_KERNEL);
1180 if (p_tas256x->devs[i] == NULL) { 1186 if (p_tas256x->devs[i] == NULL) {
1187 kfree(p_tas256x->devs);
1181 rc = -1; 1188 rc = -1;
1182 break; 1189 break;
1183 } 1190 }
@@ -1329,7 +1336,7 @@ static int tas256x_i2c_probe(struct i2c_client *p_client,
1329 1336
1330 plat_data = devm_kzalloc(&p_client->dev, 1337 plat_data = devm_kzalloc(&p_client->dev,
1331 sizeof(struct linux_platform), GFP_KERNEL); 1338 sizeof(struct linux_platform), GFP_KERNEL);
1332 if (p_tas256x == NULL) { 1339 if (plat_data == NULL) {
1333 n_result = -ENOMEM; 1340 n_result = -ENOMEM;
1334 goto err; 1341 goto err;
1335 } 1342 }
@@ -1513,8 +1520,10 @@ static int tas256x_i2c_remove(struct i2c_client *p_client)
1513 for (i = 0; i < p_tas256x->mn_channels; i++) { 1520 for (i = 0; i < p_tas256x->mn_channels; i++) {
1514 if (gpio_is_valid(p_tas256x->devs[i]->mn_reset_gpio)) 1521 if (gpio_is_valid(p_tas256x->devs[i]->mn_reset_gpio))
1515 gpio_free(p_tas256x->devs[i]->mn_reset_gpio); 1522 gpio_free(p_tas256x->devs[i]->mn_reset_gpio);
1523
1516 if (gpio_is_valid(p_tas256x->devs[i]->mn_irq_gpio)) 1524 if (gpio_is_valid(p_tas256x->devs[i]->mn_irq_gpio))
1517 gpio_free(p_tas256x->devs[i]->mn_irq_gpio); 1525 gpio_free(p_tas256x->devs[i]->mn_irq_gpio);
1526
1518 kfree(p_tas256x->devs[i]); 1527 kfree(p_tas256x->devs[i]);
1519 } 1528 }
1520 1529