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

Commit 761ce6cd authored by Pallavi's avatar Pallavi Committed by Shiv Maliyappanahalli
Browse files

hal: fix null pointer references and data initialization errors

  - add null pointer check and initialize uninitialized variables

CRs-Fixed: 2075786
Change-Id: I3e983673f36005be795a0d3adb3c54b5dcf0f002
parent 93f080ec
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -114,6 +114,11 @@ static void send_cmd_l(request_t r)
    struct keep_alive_cmd *cmd =
        (struct keep_alive_cmd *)calloc(1, sizeof(struct keep_alive_cmd));

    if (cmd == NULL) {
        ALOGE("%s: cmd is NULL", __func__);
        return -ENOMEM;
    }

    cmd->req = r;
    list_add_tail(&ka.cmd_list, &cmd->node);
    pthread_cond_signal(&ka.cond);
@@ -271,6 +276,12 @@ void audio_extn_keep_alive_start()

    /*send calibration*/
    usecase = calloc(1, sizeof(struct audio_usecase));

    if (usecase == NULL) {
        ALOGE("%s: usecase is NULL", __func__);
        rc = -ENOMEM;
        goto exit;
    }
    usecase->type = PCM_PLAYBACK;
    usecase->out_snd_device = snd_device;

+1 −1
Original line number Diff line number Diff line
@@ -325,7 +325,7 @@ ssize_t qahwi_out_write_v2(struct audio_stream_out *stream, const void* buffer,
            bytes_written = bytes;
        }
        ALOGV("%s: flag 0x%x, bytes %zd, read %zd, ret %zd timestamp 0x%"PRIx64"",
              __func__, out->flags, bytes, bytes_written, ret, *timestamp);
              __func__, out->flags, bytes, bytes_written, ret, timestamp == NULL ? 0 : *timestamp);
    } else {
        bytes_written = out->qahwi_out.base.write(&out->stream, buffer, bytes);
        ALOGV("%s: flag 0x%x, bytes %zd, read %zd, ret %zd",
+3 −1
Original line number Diff line number Diff line
@@ -755,7 +755,7 @@ void *asphere_thread_func(void* data) {
    int                      reply_data;
    uint32_t                 reply_size = sizeof(int);
    uint32_t array_size = sizeof(qahw_effect_param_t) + 2 * sizeof(int32_t);
    uint32_t      buf32[array_size];
    uint32_t      buf32[array_size], buf32_2[array_size];
    qahw_effect_param_t *values;
    int enable;

@@ -794,6 +794,8 @@ void *asphere_thread_func(void* data) {
            }
            if (thr_ctxt->cmd_code == QAHW_EFFECT_CMD_ENABLE || thr_ctxt->cmd_code == QAHW_EFFECT_CMD_DISABLE) {
                enable = ((thr_ctxt->cmd_code == QAHW_EFFECT_CMD_ENABLE) ? 1 : 0);

                values = (qahw_effect_param_t *)buf32_2;
                values->psize = 2 * sizeof(int32_t);
                values->vsize = sizeof(int32_t);
                *(int32_t *)values->data = ASPHERE_PARAM_ENABLE;