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

Commit d700078f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "hal: add checks for calibration buffer allocation failures"

parents f03be9f1 119f9640
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -881,10 +881,16 @@ static int send_codec_cal(acdb_loader_get_calibration_t acdb_loader_get_calibrat
        }
        calib.get_size = 0;
        calib.buff = malloc(calib.buff_size);
        if(calib.buff == NULL) {
            ALOGE("%s mem allocation for %d bytes for %s failed\n"
                , __func__, calib.buff_size, cal_name_info[type]);
            return -1;
        }
        ret = acdb_loader_get_calibration(cal_name_info[type],
                              sizeof(struct param_data), &calib);
        if (ret < 0) {
            ALOGE("%s get_calibration failed\n", __func__);
            ALOGE("%s get_calibration failed type=%s calib.size=%d\n"
                , __func__, cal_name_info[type], codec_buffer.size);
            free(calib.buff);
            return ret;
        }
@@ -892,9 +898,10 @@ static int send_codec_cal(acdb_loader_get_calibration_t acdb_loader_get_calibrat
        codec_buffer.size = calib.data_size;
        codec_buffer.cal_type = type;
        if (ioctl(fd, SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE, &codec_buffer) < 0)
            ALOGE("Failed to call ioctl  for %s err=%d",
                                  cal_name_info[type], errno);
        ALOGD("%s cal sent for %s", __func__, cal_name_info[type]);
            ALOGE("Failed to call ioctl  for %s err=%d calib.size=%d",
                cal_name_info[type], errno, codec_buffer.size);
        ALOGD("%s cal sent for %s calib.size=%d"
            , __func__, cal_name_info[type], codec_buffer.size);
        free(calib.buff);
    }
    return ret;