Commit: d9b27da3cc93d812c5da0cc5b597cb4a92d8adb6
Parent: a2d3f2d5c5bd999c1e3606090cc961dbd16565b2
Author: Rafal Michalski <michalski.raf@gmail.com>
Committer: Johan Hedberg <johan.hedberg@intel.com>
Date: 2011-06-14 12:07:35
Tree: f12aa31b436d0b59ccb94c3083d69cc2115b503b

Fix invalid read from memory issue in AVDTP module Changing stream state from STREAMING to IDLE can be associated with side effects under some circumstances (such as terminating bluetoothd during music is streamed). In this case, after connection is lost, stream state changes from STREAMING to IDLE - "avdtp_sep_set_state" is triggered which invokes callback called "stream_state_changed" which internally invokes "avdtp_sep_set_state" (state of stream doesn't change and stays as IDLE) second time and then stream callbacks list is discarded by "stream_free" ("g_slist_free(stream->callbacks)"). After returning from callback, "stream->callbacks" list (and "l" pointer as well) is already out of date, so attempting to fetch "l->next" pointer (returned by "g_slist_next(l)" to be prepared to next iteration of "for" loop) from node on discarded list leads to invalid read issue (reported by valgrind). This patch prevents from this issue by moving "l = g_slist_next(l)" instruction just before invoking callback - loop has been modified and "while" used instead of "for" loop variant.

Diffstat

M audio/avdtp.c | 4 +++-

1 files changed, 3 insertions(+), 1 deletions(-)

View Full Diff | Patch