From 0a00efb460acb26324412aed66cc9a5ea0ebf860 Mon Sep 17 00:00:00 2001
From: Andre Noll <maan@systemlinux.org>
Date: Sat, 6 Jul 2013 23:00:14 +0200
Subject: [PATCH] audiod: Close filters in reverse order.

Otherwise, a subsequent filter might refer to a buffer reference of
the previous filter, accessing freed memory. This is not a bug right
now, as audiod only closes filters after the full buffer tree has
become inactive, i.e. after all buffer tree nodes have unregistered
their task. It's cleaner to reverse the loop though, and it has no
additional cost.
---
 audiod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/audiod.c b/audiod.c
index 8552af6b..8f2a72ac 100644
--- a/audiod.c
+++ b/audiod.c
@@ -428,7 +428,7 @@ static void close_filters(struct slot_info *s)
 	struct audio_format_info *a = afi + s->format;
 	if (a->num_filters == 0)
 		return;
-	for (i = 0; i < a->num_filters; i++) {
+	for (i = a->num_filters - 1; i >= 0; i--) {
 		struct filter_node *fn = s->fns + i;
 		struct filter *f;
 
-- 
2.39.5