From: Andre Noll <maan@systemlinux.org>
Date: Sat, 6 Jul 2013 21:00:14 +0000 (+0200)
Subject: audiod: Close filters in reverse order.
X-Git-Tag: v0.4.13~17
X-Git-Url: https://git.tue.mpg.de/?a=commitdiff_plain;h=0a00efb460acb26324412aed66cc9a5ea0ebf860;p=paraslash.git

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.
---

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;