From f58d61e7fdfc2c60aa3054d4a9467aa5e2627650 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 18 Mar 2015 11:25:09 +0200 Subject: [PATCH] audio/avrcp: Fix crash when acting as TG When acting as TG the code may end up using GetCapabilities to figure out if volume changed event is supported, this cause crashes with remote devices that don't support TG themselves because session->controller is not initialized. Note that to pass AVRCP qualification when volume changed is supported the device has to support TG as well as CT record, this is because PTS will attempt to fetch the TG record for any test that it is sending commands so devices where this crash happen most likely don't have volume control feature enabled. --- profiles/audio/avrcp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index 414ee25ab..cc26eed99 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3252,12 +3252,18 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn, case AVRCP_EVENT_ADDRESSED_PLAYER_CHANGED: case AVRCP_EVENT_UIDS_CHANGED: case AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED: + /* These events above are controller specific */ + if (!session->controller) + break; case AVRCP_EVENT_VOLUME_CHANGED: avrcp_register_notification(session, event); break; } } + if (!session->controller) + return FALSE; + if (!(events & (1 << AVRCP_EVENT_SETTINGS_CHANGED))) avrcp_list_player_attributes(session); -- 2.47.3