Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1381518rwb; Tue, 29 Nov 2022 12:48:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Vb81U1yK1u7/wRxvV1+v4aK21GBZturn9ozDbDMy9kbrRlBct0khkyySOnIbuCw40hF1i X-Received: by 2002:a17:90a:3c81:b0:219:2da4:4167 with SMTP id g1-20020a17090a3c8100b002192da44167mr14931529pjc.172.1669754888933; Tue, 29 Nov 2022 12:48:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669754888; cv=none; d=google.com; s=arc-20160816; b=OnI78mZiiSCPr+47qbhyfjGF6tGi+HqxPZDU/XfqHH2F+hAznfxhVPjfZqIRFqyBQa cZBxNjazumBVXfKX6k/40wdy5p5L0Brkj15E2uh60TSdjq2fEmqDzANYLOetB4wdp5oH R5GQ7oDMPOj0x/Zfvf59EqcrriERaz59AroqPHKbIhqX3riqHGwsl+816bld/T1BTF+r Vxr7tMow2LFuK43x3KA2QM+qXqkHnKjBQIiRh+SlS7Cmzr72QRyhS8GErpHlivhAhCw5 MTLi+H6rLUGvMNYA5RJTPxNglhwkVIgN5tSrZZHpndX+1tte8XjJkMMmUhBYTud6G21j r65A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=CrUIIPrBTmjyCzYKfPEzVfSCr2e2mHMZ7ZkF84d/32s=; b=zYHOYd47oU/AhFAKAy8AM6d+V8qjIr63hvHHH79VcN5xiECTS9eCh3r7wZaxguzMIv 2eQ+EzeB3hf7kjOBV6dZAqn2x6mteb7bqELuRL5PH/HYDUKMNg8IERlAoH4Sd6CsXjBx sE3d4T2Ym404P5mcL8UrS0RqI4JkV5ugG3KygWyAGkYQACWlY4U3R+ZH00DySxbZ/Ax8 OHLwxUxjl2vaAqWIIfaV6hYs4DTg6jMffFGX3IAQbF1CbK08vrzEEvzyl661t4P1kk2X NeF0LxuUi2wMcMvT2Y1pY6oFZCg+5f1DbEpgh9cywEeRoERwCzzpNIJmjc2P8uKtTogW qLLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LJGbEhNH; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 125-20020a630283000000b00476e90fb3b7si15993089pgc.577.2022.11.29.12.47.56; Tue, 29 Nov 2022 12:48:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=LJGbEhNH; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231151AbiK2UqG (ORCPT + 99 others); Tue, 29 Nov 2022 15:46:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235992AbiK2UqF (ORCPT ); Tue, 29 Nov 2022 15:46:05 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AED2D750 for ; Tue, 29 Nov 2022 12:46:04 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id s196so14146084pgs.3 for ; Tue, 29 Nov 2022 12:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=CrUIIPrBTmjyCzYKfPEzVfSCr2e2mHMZ7ZkF84d/32s=; b=LJGbEhNHBXgz3Z00yyXf9eaIZScNuqmvgveZsbb6mZuvaUB++bUemzfOQV6Z+KA1ux ZHA+zdYisisfo14GmRkrdpNq8PmJlXh/Mt69I0rxMJpiYSlGicexEreqGE+8HRU/fG79 nWQpOIN1JfmFlg5GtwgyB0YG4Ku00su4TfW5hZSCibZqe+wwx+7hFTwr4LZncYIsxpeh axAyFwFp9xU9KQE8W8NH+BA2dCmuosKEfcQ9dh1YG4LI9BiRq2ZY9xfMFYL8lDFTFvXS +Mxrxa8sfbN30mZLSZerYyBAynwptcvlbuBeeNA6HU5LeFYZL2yG0mspST5thazUkZ4S yC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CrUIIPrBTmjyCzYKfPEzVfSCr2e2mHMZ7ZkF84d/32s=; b=BMRAgDdAB2B6vrjn4OigmkQZO0TJhhPm28L5P34JolvqFjZo66rssO8rypGFFFrepQ J9HthT2fKWrQvHMcXXhycJGr17WkcFTyqIcnyunQTvrflUaJuEI42FuQEjZD5UZiwGcz SH+H7dg8NUg6kyGfeFfj5U1vBsfHLs5MCKtYOzs1r5Qyn4/xe1E5q88DHKX1gXkr3ahH hNnBwflWTXYdae+JCQzAiTxFxCcR3DdV8UYAMY01baULcXbaggyPRU4qRxwv2xDfpMDX pKv4dMdlU9DicNe9zN6CGyReoYaaOKCtu5K4QnZZjNSmXfpwjFIX6X6c9aH47INt/nNx RP5A== X-Gm-Message-State: ANoB5plxSXBdOnXPptjiSuWsABA72RBV8RVukQlpCbMbD3/gYvSpVeS1 ADvAZi8MwWh9L4tCUNVt0V2uxrlhIQhyYw== X-Received: by 2002:aa7:96d2:0:b0:574:2447:947d with SMTP id h18-20020aa796d2000000b005742447947dmr35929082pfq.32.1669754763418; Tue, 29 Nov 2022 12:46:03 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i7-20020a17090332c700b001887e30b9ddsm11216214plr.257.2022.11.29.12.46.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 12:46:02 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] media: Fix crash when transport configuration changes Date: Tue, 29 Nov 2022 12:45:56 -0800 Message-Id: <20221129204556.1535821-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221129204556.1535821-1-luiz.dentz@gmail.com> References: <20221129204556.1535821-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz In case of BAP the same transport may be reconfigured multiple times which means it would appears multiple times on endpoint->transports leading to a crash when disconnecting as the code would attempt to destroy the same object multiple times. --- profiles/audio/media.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index c9328ab9bd6e..6947cf96392e 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -1057,6 +1057,8 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, path = media_transport_get_path(transport); bt_bap_stream_set_user_data(stream, (void *)path); + endpoint->transports = g_slist_append(endpoint->transports, + transport); } msg = dbus_message_new_method_call(endpoint->sender, endpoint->path, @@ -1064,7 +1066,7 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, "SetConfiguration"); if (msg == NULL) { error("Couldn't allocate D-Bus message"); - media_transport_destroy(transport); + endpoint_remove_transport(endpoint, transport); return FALSE; } @@ -1073,8 +1075,6 @@ static int pac_config(struct bt_bap_stream *stream, struct iovec *cfg, data->cb = cb; data->user_data = user_data; - endpoint->transports = g_slist_append(endpoint->transports, transport); - dbus_message_iter_init_append(msg, &iter); path = media_transport_get_path(transport); -- 2.37.3