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

Commit bdda2f21 authored by Aditya Bavanari's avatar Aditya Bavanari
Browse files

hal: Fix for a native crash in select_devices

In case of speaker protection, stream.in is not filled
and hence when it tries to access stream.in->devices for
spkr-vi-record usecase,crash occurs.In case of HDMI
keep_alive usecase,stream.out is not filled.
Add a null check before accessing stream.in and
stream.out pointers.

Change-Id: I5fafaa71d13ce234908dc2e24979d69a38435f62
CRs-Fixed: 1076923
parent a56824d7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1291,6 +1291,10 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
    if ((usecase->type == VOICE_CALL) ||
        (usecase->type == VOIP_CALL)  ||
        (usecase->type == PCM_HFP_CALL)) {
        if(usecase->stream.out == NULL) {
            ALOGE("%s: stream.out is NULL", __func__);
            return -EINVAL;
        }
        out_snd_device = platform_get_output_snd_device(adev->platform,
                                                        usecase->stream.out);
        in_snd_device = platform_get_input_snd_device(adev->platform, usecase->stream.out->devices);
@@ -1334,6 +1338,10 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
            }
        }
        if (usecase->type == PCM_PLAYBACK) {
            if (usecase->stream.out == NULL) {
                ALOGE("%s: stream.out is NULL", __func__);
                return -EINVAL;
            }
            usecase->devices = usecase->stream.out->devices;
            in_snd_device = SND_DEVICE_NONE;
            if (out_snd_device == SND_DEVICE_NONE) {
@@ -1346,6 +1354,10 @@ int select_devices(struct audio_device *adev, audio_usecase_t uc_id)
                }
            }
        } else if (usecase->type == PCM_CAPTURE) {
            if (usecase->stream.in == NULL) {
                ALOGE("%s: stream.in is NULL", __func__);
                return -EINVAL;
            }
            usecase->devices = usecase->stream.in->device;
            out_snd_device = SND_DEVICE_NONE;
            if (in_snd_device == SND_DEVICE_NONE) {