Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 061a9499 authored by Krishnankutty Kolathappilly's avatar Krishnankutty Kolathappilly
Browse files

hal: Fix memory leak in HAL debug logs

String returned from str_parms_to_str for set/get parameter in
debug logs is not de-allocated. Fix is to make sure the memory
allocated for set parameter key value pair is de-allocated.

CRs-Fixed: 610079
Change-Id: I5027d8f1741c9e7223e7b4721f8d5473404998d3
parent 870ee8a2
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -326,9 +326,12 @@ void audio_extn_get_parameters(const struct audio_device *adev,
                              struct str_parms *query,
                              struct str_parms *reply)
{
    char *kv_pairs = NULL;
    audio_extn_get_afe_proxy_parameters(query, reply);

    ALOGD("%s: returns %s", __func__, str_parms_to_str(reply));
    kv_pairs = str_parms_to_str(reply);
    ALOGD_IF(kv_pairs != NULL, "%s: returns %s", __func__, kv_pairs);
    free(kv_pairs);
}

#ifdef AUXPCM_BT_ENABLED
+7 −2
Original line number Diff line number Diff line
@@ -1481,8 +1481,9 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
    char value[256] = {0};
    int val;
    int ret = 0, err;
    char *kv_pairs = str_parms_to_str(parms);

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);

    err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
    if (err >= 0) {
@@ -1527,6 +1528,7 @@ int platform_set_parameters(void *platform, struct str_parms *parms)
    }

    ALOGV("%s: exit with code(%d)", __func__, ret);
    free(kv_pairs);
    return ret;
}

@@ -1625,6 +1627,7 @@ void platform_get_parameters(void *platform,
    char value[256] = {0};
    int ret;
    int fluence_type;
    char *kv_pairs = NULL;

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE_TYPE,
                            value, sizeof(value));
@@ -1660,7 +1663,9 @@ void platform_get_parameters(void *platform,
        str_parms_add_str(reply, AUDIO_PARAMETER_KEY_VOLUME_BOOST, value);
    }

    ALOGV("%s: exit: returns - %s", __func__, str_parms_to_str(reply));
    kv_pairs = str_parms_to_str(reply);
    ALOGV_IF(kv_pairs != NULL, "%s: exit: returns - %s", __func__, kv_pairs);
    free(reply);
}

/* Delay in Us */
+3 −1
Original line number Diff line number Diff line
@@ -364,8 +364,9 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
    char value[32];
    int val;
    int ret = 0, err;
    char *kv_pairs = str_parms_to_str(parms);

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);

    ret = voice_extn_set_parameters(adev, parms);
    if (ret != 0)
@@ -413,6 +414,7 @@ int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)

done:
    ALOGV("%s: exit with code(%d)", __func__, ret);
    free(kv_pairs);
    return ret;
}

+7 −2
Original line number Diff line number Diff line
@@ -411,8 +411,9 @@ int voice_extn_compress_voip_set_parameters(struct audio_device *adev,
    int ret = 0, err, rate;
    int min_rate, max_rate;
    bool flag;
    char *kv_pairs = str_parms_to_str(parms);

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);

    err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOIP_RATE,
                            value, sizeof(value));
@@ -453,6 +454,7 @@ int voice_extn_compress_voip_set_parameters(struct audio_device *adev,

done:
    ALOGV("%s: exit", __func__);
    free(kv_pairs);
    return ret;
}

@@ -499,6 +501,7 @@ void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
{
    int ret, val;
    char value[32]={0};
    char *kv_pairs = NULL;

    ALOGV("%s: enter", __func__);

@@ -511,7 +514,9 @@ void voice_extn_compress_voip_in_get_parameters(struct stream_in *in,
            str_parms_add_int(reply, AUDIO_PARAMETER_KEY_VOIP_CHECK, false);
    }

    ALOGD("%s: exit: return - %s", __func__, str_parms_to_str(reply));
    kv_pairs = str_parms_to_str(reply);
    ALOGD_IF(kv_pairs != NULL, "%s: exit: return - %s", __func__, kv_pairs);
    free(kv_pairs);
}

int voice_extn_compress_voip_out_get_buffer_size(struct stream_out *out)
+9 −4
Original line number Diff line number Diff line
@@ -427,8 +427,9 @@ int voice_extn_set_parameters(struct audio_device *adev,
    char *str;
    int value;
    int ret = 0, err;
    char *kv_pairs = str_parms_to_str(parms);

    ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
    ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);

    err = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_VSID, &value);
    if (err >= 0) {
@@ -458,6 +459,7 @@ int voice_extn_set_parameters(struct audio_device *adev,

done:
    ALOGV("%s: exit with code(%d)", __func__, ret);
    free(kv_pairs);
    return ret;
}

@@ -485,9 +487,10 @@ void voice_extn_get_parameters(const struct audio_device *adev,
{
    int ret;
    char value[VOICE_EXTN_PARAMETER_VALUE_MAX_LEN] = {0};
    char *str = NULL;
    char *str = str_parms_to_str(query);

    ALOGV("%s: enter %s", __func__, str_parms_to_str(query));
    ALOGV_IF(str != NULL, "%s: enter %s", __func__, str);
    free(str);

    ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_AUDIO_MODE, value,
                            sizeof(value));
@@ -507,7 +510,9 @@ void voice_extn_get_parameters(const struct audio_device *adev,
    }
    voice_extn_compress_voip_get_parameters(adev, query, reply);

    ALOGV("%s: exit: returns \"%s\"", __func__, str_parms_to_str(reply));
    str = str_parms_to_str(reply);
    ALOGV_IF(str != NULL, "%s: exit: returns \"%s\"", __func__, str);
    free(str);
}

void voice_extn_out_get_parameters(struct stream_out *out,