From patchwork Thu Nov 5 06:29:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 319436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 932D6C00A89 for ; Thu, 5 Nov 2020 06:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25B1C2071A for ; Thu, 5 Nov 2020 06:30:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="u46XGnv8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729653AbgKEGaE (ORCPT ); Thu, 5 Nov 2020 01:30:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbgKEGaD (ORCPT ); Thu, 5 Nov 2020 01:30:03 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2663C0613CF for ; Wed, 4 Nov 2020 22:30:03 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id a24so766036pfo.3 for ; Wed, 04 Nov 2020 22:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=1ERKUPf2W0TioMz6bk7mIf8B9LgdLBR9YkYepyUVNC8=; b=u46XGnv8FmpktTWXDRZyzlxp82SeLOiCySfzZ8KxXNHnlXHK1y/iZdJnXxNIhHYPRu p35esVa/SHzyaSVsZknP8jzG4dqpnQG4IhgJYq7pPyTpPjSTY7Ux6c7yHPfa3MyThffA pad5pKt2p1ZDdcCN2JUIVWDonBwBJ6ZzIOGw6Bzc3rwUBuhJXiGmoLkNgBNvSQ7wLcGx EWbfKjRyje1V3Irhg/pZPZLRov+cow2gXEO5sRQbbX/zNseTHvzkVmAgWAG0HxLODPbi /JmDsylhWZXDeskwGPjR5eor3IKxRaNgkS7EbTVBPoz5hig26cWoeLgJXGjk4l1eKmGl 8OcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=1ERKUPf2W0TioMz6bk7mIf8B9LgdLBR9YkYepyUVNC8=; b=eAcgAxMpoFcEDi9TBEMvOFNLx0nrHL8U5GtyYbAlFe5zdZ/BuqN6E9GbzF1F+cAcFI 2qo/s8Q+55eVjvhu0WDELJt7SouRKCF6PDLO2qL20AszkWx8ErZwtRh4nkhjBjj8tTFI 6RTz1OhWDPEG7YeGZbmuPJegGwGHO3EP154RLwPSpuQU7m0v0xjk89EVPyLT2wwg/4+7 ypFnHk2pmLWNel8vZAZGSeS/D2WnbKFXlWDB93Bh85u+Yxofztp2aDSUZ7glyqGu2LK1 MUHhYfqD0ePBCDgZlYn63AvlhALKBysUchLfcTuJL83xwJTuQ9/4pHihbLmodlGuPlQk KLbg== X-Gm-Message-State: AOAM532QY+1dnM3fOmjfdJM2cWShEz0SXEoFlMcvpHIOMCYrMUx2DJQx c+dcPfTYgwSqnBDhfCotOHY/pGentcAUQnH9fcUXQaM/eeY/gIgRqLi8I0IRDU3nREnhxkEkynZ DLFkDtJquVOKnBeIrMKnC4wA7bE9JeCInkpxmW8C4dCH08b6hiyQqor0x2peefPwzDVPjRNKgK0 zx X-Google-Smtp-Source: ABdhPJyn2S/CtYFU3Lvqe/8w0F8NpeW9ScBUj2p+x3mhF1HF1nOqK3eM6K2uZELSn6Jqw+MDbRN+dwvgO0PR Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a17:90a:1992:: with SMTP id 18mr974328pji.67.1604557803233; Wed, 04 Nov 2020 22:30:03 -0800 (PST) Date: Thu, 5 Nov 2020 14:29:51 +0800 Message-Id: <20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v2 1/3] policy: add checks before connecting From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka When policy_connect() is called, there might be a case where the device is not ready, or even the adapter is down. Add some checks by calling btd_device_connect_services() instead of directly calling btd_service_connect(). --- Changes in v2: * Add adapter status check in btd_service_connect() instead of using btd_device_connect_services() src/service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/service.c b/src/service.c index d810fc3b05..21a52762e6 100644 --- a/src/service.c +++ b/src/service.c @@ -229,6 +229,9 @@ int btd_service_connect(struct btd_service *service) if (!profile->connect) return -ENOTSUP; + if (!btd_adapter_get_powered(device_get_adapter(service->device))) + return -ENETDOWN; + switch (service->state) { case BTD_SERVICE_STATE_UNAVAILABLE: return -EINVAL; From patchwork Thu Nov 5 06:29:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 317917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4525DC00A89 for ; Thu, 5 Nov 2020 06:30:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF7E420728 for ; Thu, 5 Nov 2020 06:30:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tTndDfsy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729744AbgKEGaN (ORCPT ); Thu, 5 Nov 2020 01:30:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbgKEGaM (ORCPT ); Thu, 5 Nov 2020 01:30:12 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B2C3C0613CF for ; Wed, 4 Nov 2020 22:30:12 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id z125so745492pfc.12 for ; Wed, 04 Nov 2020 22:30:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=AiMlLJgHixAXDnCP8ZY72ZbeqLVurDL36FqDlebGM/8=; b=tTndDfsyZKEguKJQxnALqnG9KJjuoGXlHY5KFCfuoJ+XTVg+OWf46kBK+AwVXXWnOO BL0O8lpoRwJ2UjhXQpR4etHyMel2QOHlW3l+lj54PiUO1WmzTb9Oce08wTbY2cjpTxab LNDSUVfBqLRNuYIeojrKeD25nbrgA5F7VftXMIi/ykw5BsDrz1C1hOOMjeJ02XIimPFS HbgEQzxwU9Fr2bl3EAyYpEwt4Ab71blIcDnS1gGr0jfBqvlIzV/0HYFWTtdT+glKRipX 1EY42lzxDyD1DgCkYqtTZBOT1UEhe2LsrUMMYoVAwPL0H65YEU7icJGUPPnpsyYNL0H/ 8G/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AiMlLJgHixAXDnCP8ZY72ZbeqLVurDL36FqDlebGM/8=; b=GtfYpXN008u4HYjBmgHymUo/0J6L80JbMNh7mtxMj6XTg2jlligPIiz/orMSBtPcPK xk6CI2hi1MIZvwqDnUYSIhpg3Vva6JjiVJbv4A1SvuBx9IWsF+cgxVJjZDx3W2oEGLw4 g1AO3KBTg5iv5jJ3Vd6/nYLql7pBYnK5KXhtf3b2XcDe8YTFGw/+wS/DjHegQm7RCWfC jPckN0Nr5fwEABRYA9oxc96iC3o4Bb8IxP1leY8iANSJsp/87mOl6+LVI8vpqsznytcJ xz0hTaQ91soGjCroAlYxnbkcPe8EgjNjqfufqFITmOX6SkhFU5LuOkFAjH+RJ1+n5WYE zB4w== X-Gm-Message-State: AOAM531cdogfcCEeWapMxynw3Y7Gc62pZjsZqeN8UnVNGt0Bu0Cx54cB oIE8UalOCVavFhN/5eiXIEtx8OKr0x8zC0j/1dG/aSZEcN4fSpv66PrYWzVMmxaApxQ9Fap+7Yu UJmg7wz6XEzqjsYDUMNao2P27Xgwo6DCX+mwVasatk9JvPYoZaqWLqcRnngZHmiGTBJhVBl9lt1 PU X-Google-Smtp-Source: ABdhPJw0s1uOovkKt/nW0FF42M9I+DtmEj4TkGxeYO3QYBJgCVLhhQEZHKEdWQmcy5mLYPQMKXnd1xO0IqSS Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:aa7:8616:0:b029:18b:421b:9168 with SMTP id p22-20020aa786160000b029018b421b9168mr661665pfn.33.1604557811679; Wed, 04 Nov 2020 22:30:11 -0800 (PST) Date: Thu, 5 Nov 2020 14:29:52 +0800 In-Reply-To: <20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Message-Id: <20201105142838.Bluez.v2.2.I4c872b9b8fdee53a335db41acbb6e59fe9692cc5@changeid> Mime-Version: 1.0 References: <20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v2 2/3] audio: unref session when failed to setup From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka There is a possibility to miss unref-ing when source/sink fails at setup. Reviewed-by: Sonny Sasaka --- (no changes since v1) profiles/audio/sink.c | 5 ++++- profiles/audio/source.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 134d157bc6..d672670e25 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -258,8 +258,11 @@ gboolean sink_setup_stream(struct btd_service *service, struct avdtp *session) sink->connect_id = a2dp_discover(sink->session, discovery_complete, sink); - if (sink->connect_id == 0) + if (sink->connect_id == 0) { + avdtp_unref(sink->session); + sink->session = NULL; return FALSE; + } return TRUE; } diff --git a/profiles/audio/source.c b/profiles/audio/source.c index fca85d4cb3..c706c928a7 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -259,8 +259,11 @@ gboolean source_setup_stream(struct btd_service *service, source->connect_id = a2dp_discover(source->session, discovery_complete, source); - if (source->connect_id == 0) + if (source->connect_id == 0) { + avdtp_unref(source->session); + source->session = NULL; return FALSE; + } return TRUE; } From patchwork Thu Nov 5 06:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archie Pusaka X-Patchwork-Id: 319435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5537C00A89 for ; Thu, 5 Nov 2020 06:30:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E89420728 for ; Thu, 5 Nov 2020 06:30:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KSVb6eKX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbgKEGaT (ORCPT ); Thu, 5 Nov 2020 01:30:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728827AbgKEGaS (ORCPT ); Thu, 5 Nov 2020 01:30:18 -0500 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7253C0613CF for ; Wed, 4 Nov 2020 22:30:16 -0800 (PST) Received: by mail-pg1-x549.google.com with SMTP id b17so558636pgd.16 for ; Wed, 04 Nov 2020 22:30:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=3uB46e4wAC56usX3WUKxk/x85EKQRpS+HGXlr+AFs78=; b=KSVb6eKXDB9ua+A9M8/mPeequa1NilN1qmbKfuMZ7w/KUqTqttF3zl86Veq4B1FcEu BD8/Z/rrZ9UIFjQUj8aF8JUyJvKtBBkxq592ZfqMSjTMgHkc3ZqmiGQ14vVWkJ0LnJYK CYAh1Sy74vV/Nb6MzPNi2m5Vd/ivi8MFDIw6oKBFtzse25Yq0pz/R27VF5wS98bGp0zd 9KzciXY1qGcksDqCsASVCElVVs16eUvXEsH73+XnfGxnOm9b0JznvRqHPIC91CMZpO1l P01v3H0831QjohgXHtP+uEXwc4/dcwH1emqNBti3mq4x7sLgxcyzbG7IJdquq4VmSBXs sDsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3uB46e4wAC56usX3WUKxk/x85EKQRpS+HGXlr+AFs78=; b=qejgsjH/rkEwwTTc4NNgvptBK6utQ/fODRg7rx5lN+EfbWwHTkgdy0bk3sy3oaDtAS V0agLUdu2LTHHeqxsbAcbhkZJvdQq/1gmydQv60uhFrihhtBzAiI2O4MX08FD4OEXQZW j7kFr5LZMmRixnaN1NRLQ7bRJ/NMT+R7c9che1XVoYJqr0TlkDnEgGRGs7rlY+qJHSpm 9URB1RCpuVlwFNMCMBT+dQ/pMyZP+7hG4dzChfSf7o1EMFhn9QUEMSl/4AyHutBTUpqJ 0uUWU9LkheYDlYElWPFs464kXMe+oSCUbAeFtFg6rZrY+G+ZbQovPwbhVbWewSFyb+8v 35cw== X-Gm-Message-State: AOAM532UHDgeJgricSenqejkcXBb6xeAL614muAUTs+4jUYLj3oVJx8W NlD1dK/XTYt2rzUfsj3PoTX4w58NFUNz6hDvJIYO2xMkt2uE6lltfM++wUF96sInAI80ssmDba9 JxPeMXx/C8WFD4algEjfMR1rFsZ5azuaM9RvUQYP2iZWpHoMJYSefQGxEl47cSnCo7fooZEV+e/ mC X-Google-Smtp-Source: ABdhPJzHswnnv6Og5ge0abEVutamk93XcF10LZF73Ukrz9i/Jfo2LKa1zIeqbfuqJOXo0OBdsGSV1g7RIQX6 Sender: "apusaka via sendgmr" X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:b:f693:9fff:fef4:2347]) (user=apusaka job=sendgmr) by 2002:a62:fb10:0:b029:18b:823a:535f with SMTP id x16-20020a62fb100000b029018b823a535fmr1040764pfm.42.1604557816227; Wed, 04 Nov 2020 22:30:16 -0800 (PST) Date: Thu, 5 Nov 2020 14:29:53 +0800 In-Reply-To: <20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> Message-Id: <20201105142838.Bluez.v2.3.Ib69ea31cb69840b941b725a1d889473c5e6cac97@changeid> Mime-Version: 1.0 References: <20201105142838.Bluez.v2.1.Ibb93fb0188187d11151855d2dcc737640b2b81da@changeid> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [Bluez PATCH v2 3/3] audio/avdtp: Report failure in disconnected state From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Archie Pusaka A2DP are relying on the disconnected state callback to do cleanup. If failure occurs when AVDTP are already in the disconnected state, we didn't make any transition state, therefore A2DP would miss this event. This patch allows the transition to disconnected state, even though we are previously already in the disconnected state. Reviewed-by: Sonny Sasaka --- (no changes since v1) profiles/audio/avdtp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c index 4c39088b8f..16fa20bba7 100644 --- a/profiles/audio/avdtp.c +++ b/profiles/audio/avdtp.c @@ -2612,6 +2612,11 @@ static int send_req(struct avdtp *session, gboolean priority, if (session->state == AVDTP_SESSION_STATE_DISCONNECTED) { session->io = l2cap_connect(session); if (!session->io) { + /* Report disconnection anyways, as the other layers + * are using this state for cleanup. + */ + avdtp_set_state(session, + AVDTP_SESSION_STATE_DISCONNECTED); err = -EIO; goto failed; }