hal : Fix data initialization and input validation errors
Initialize uninitialized variables and add null check to
avoid following errors
119251, 119255, 119256, 119257, 119258
144012, 913366, 119249, 119250, 58938
Change-Id: I09d35977c9c3abf5819d5c72506c8d157158e212
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index 1335ee9..44ff952 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -421,6 +421,7 @@
struct timespec ts;
bool acquire_device = false;
+ status.status = 0;
if (!adev) {
ALOGE("%s: Invalid params", __func__);
return -EINVAL;
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index fe502da..923135e 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -1311,14 +1311,14 @@
if(property_get_bool("use.qti.sw.alac.decoder", false)) {
ALOGD("Alac software decoder is available...removing alac from DSP decoder list");
- strncpy(dsp_only_decoders_mime[count],"none",5);
+ strlcpy(dsp_only_decoders_mime[count],"none",5);
}
} else if (!strncmp(MEDIA_MIMETYPE_AUDIO_APE, dsp_only_decoders_mime[count],
strlen(dsp_only_decoders_mime[count]))) {
if(property_get_bool("use.qti.sw.ape.decoder", false)) {
ALOGD("APE software decoder is available...removing ape from DSP decoder list");
- strncpy(dsp_only_decoders_mime[count],"none",5);
+ strlcpy(dsp_only_decoders_mime[count],"none",5);
}
}
}
@@ -1445,7 +1445,7 @@
sizeof(struct param_data), &calib);
if (ret < 0) {
ALOGE("%s get_calibration failed type=%s calib.size=%d\n"
- , __func__, cal_name_info[type], codec_buffer.size);
+ , __func__, cal_name_info[type], calib.buff_size);
free(calib.buff);
continue;
}
@@ -1619,13 +1619,14 @@
/* update wsa combo supported flag based on sound card name */
/* wsa combo flag needs to be set to true only for hardware
combinations which has support for both wsa and non-wsa speaker */
- if (snd_card_name && ((!strncmp(snd_card_name, "msm8953-snd-card-mtp",
- sizeof("msm8953-snd-card-mtp"))) ||
- (!strncmp(snd_card_name, "msm8952-skum-snd-card",
- sizeof("msm8952-skum-snd-card"))))) {
- *is_wsa_combo_supported = true;
- } else {
- *is_wsa_combo_supported = false;
+ *is_wsa_combo_supported = false;
+ if(snd_card_name) {
+ if ((!strncmp(snd_card_name, "msm8953-snd-card-mtp",
+ sizeof("msm8953-snd-card-mtp")) ||
+ (!strncmp(snd_card_name, "msm8952-skum-snd-card",
+ sizeof("msm8952-skum-snd-card"))))) {
+ *is_wsa_combo_supported = true;
+ }
}
}
closedir(tdir);
@@ -2306,11 +2307,14 @@
int native_audio_set_params(struct platform_data *platform,
struct str_parms *parms, char *value, int len)
{
- int ret = 0;
+ int ret = -1;
struct audio_usecase *usecase;
struct listnode *node;
int mode = NATIVE_AUDIO_MODE_INVALID;
+ if (!value)
+ return ret;
+
ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO_MODE,
value, len);
if (ret >= 0) {
diff --git a/post_proc/bundle.c b/post_proc/bundle.c
index 2bc7fad..d39a8b7 100644
--- a/post_proc/bundle.c
+++ b/post_proc/bundle.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
* Copyright (C) 2013 The Android Open Source Project
@@ -287,7 +287,7 @@
__attribute__ ((visibility ("default")))
int offload_effects_bundle_hal_stop_output(audio_io_handle_t output, int pcm_id)
{
- int ret;
+ int ret = -1;
struct listnode *node;
struct listnode *fx_node;
output_context_t *out_ctxt;