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

Commit c0b53092 authored by Ben Romberger's avatar Ben Romberger Committed by David Keitel
Browse files

ASoC: msm: qdsp6v2: Correctly free ASM no wait queue



Remove improper deletion of list head and protect list
deletion with spinlock. Spinlock protects the list
from access in ADSP callback at the same time the
list is being deallocated.

Change-Id: I1b102cd99e7c80e1dfd4e2054b9ba7e0ca26d6a7
Signed-off-by: default avatarBen Romberger <bromberg@codeaurora.org>
parent 38ebaf2f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2012-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
 * Author: Brian Swetland <swetland@google.com>
 *
 * This software is licensed under the terms of the GNU General Public
@@ -423,6 +423,7 @@ static void q6asm_session_free(struct audio_client *ac)
{
	struct list_head		*ptr, *next;
	struct asm_no_wait_node		*node;
	unsigned long			flags;

	pr_debug("%s: sessionid[%d]\n", __func__, ac->session);
	rtac_remove_popp_from_adm_devices(ac->session);
@@ -431,12 +432,13 @@ static void q6asm_session_free(struct audio_client *ac)
	ac->perf_mode = LEGACY_PCM_MODE;
	ac->fptr_cache_ops = NULL;

	spin_lock_irqsave(&ac->no_wait_que_spinlock, flags);
	list_for_each_safe(ptr, next, &ac->no_wait_que) {
		node = list_entry(ptr, struct asm_no_wait_node, list);
		list_del(&node->list);
		kfree(node);
	}
	list_del(&ac->no_wait_que);
	spin_unlock_irqrestore(&ac->no_wait_que_spinlock, flags);
	return;
}