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

Commit ce2b9fab authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Gerrit - the friendly Code Review server
Browse files

hal: Fixes in audio patch removal and device utilities

Fix use-after-free of patch_info in release_audio_patch.
Correct is_single_device_type_equal API in device_utils.

Change-Id: I307bdb5fc45aba82a62f7a49f1724de3873fed89
parent 7098e119
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -449,13 +449,14 @@ audio_devices_t get_device_types(struct listnode *devices)
bool is_single_device_type_equal(struct listnode *devices,
                                 audio_devices_t type)
{
    struct listnode *node = devices;
    struct listnode *node;
    struct audio_device_info *item = NULL;

    if (devices == NULL)
        return false;

    if (list_length(devices) == 1) {
        node = devices->next;
        item = node_to_item(node, struct audio_device_info, list);
        if (item != NULL && (item->type == type))
            return true;
+5 −4
Original line number Diff line number Diff line
@@ -9880,9 +9880,10 @@ int adev_release_audio_patch(struct audio_hw_device *dev,
    }

    // Remove patch and reset patch handle in stream info
    patch_type_t patch_type = p_info->patch_type;
    patch_map_remove_l(adev, handle);
    if (p_info->patch_type == PATCH_PLAYBACK ||
        p_info->patch_type == PATCH_CAPTURE) {
    if (patch_type == PATCH_PLAYBACK ||
        patch_type == PATCH_CAPTURE) {
        struct audio_stream_info *s_info =
            hashmapGet(adev->io_streams_map, (void *) (intptr_t) io_handle);
        if (s_info == NULL) {
@@ -9898,9 +9899,9 @@ int adev_release_audio_patch(struct audio_hw_device *dev,
    if (stream != NULL) {
        struct listnode devices;
        list_init(&devices);
        if (p_info->patch_type == PATCH_PLAYBACK)
        if (patch_type == PATCH_PLAYBACK)
            ret = route_output_stream((struct stream_out *) stream, &devices);
        else if (p_info->patch_type == PATCH_CAPTURE)
        else if (patch_type == PATCH_CAPTURE)
            ret = route_input_stream((struct stream_in *) stream, &devices, input_source);
    }