Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp2841960rwo; Mon, 24 Jul 2023 02:00:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHFMQduAaYCIN28rAPe8LlPu6pczn9g9elIcSm3r+KstdUmb/zAb5/J4Nychy+3GvOm/t0P X-Received: by 2002:a17:907:1dc3:b0:98d:f6eb:3b03 with SMTP id og3-20020a1709071dc300b0098df6eb3b03mr9362013ejc.56.1690189244373; Mon, 24 Jul 2023 02:00:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690189244; cv=pass; d=google.com; s=arc-20160816; b=FiFHo1I2VI+gWaGeTlCzf11rmultryYs8bkZ2lWXm9qAXscez6vXjYVmm+4LVRrnhG KCW4+CyJTLWqvn/F7q9GOdGsjKaFkIFvtGDeTL1sfTGu5PdlYxIJEBpOvrA6DETq/00r aW5Js58MDVVwBd4k+jeaoS2IFtheP+V4rlzi57T6xvgeLG8sirVfZjKMh9mmO+kEXjTv pjHPanbEmpZfDpF37bw4LtBKetlNa3rOdaU9WFtQn/z1UyKD5/RAEgdVwBd9r1T2ccuP v9NmYuC8MES1/mNNUkAyq0bSd7OK+XqGg9sK28kvPmCvT8tAoYHoYBgW/P5qO1bpA380 Bmbg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cp6lHxd6f22aUF5HEP9QvRTWR44J5m11pJnIh1DrzdM=; fh=O7b9e/0FHf0lC36zxfkGCP11r7lJVOROe7GJbtvFS9U=; b=pNjApsZ+upihH/2ROPR741yEnsYi66LzYpd0H9Ouzfmr7GzhaFdnbqaAaZNAdxzocy Q/sWHfZP8/+Q8laMOt9pG7j/nn5VBFdulrikolOaEFMq5f8NOK3sQztXkteHe2hjT73K 8YC2Ofr9Pju3BWEbDiXk1xnKykJlr1+ziP6twxyDokLMqp5XZ7rfhXOUvjEaqzEmk587 bmsHIUvB1YdwRuOvbZKkrlv3Vvf2NuJMdS98jhdtE00TJVFCGBFAd99G6T/WytHIKfPi bsz3687DQcADEA2VvjCZQlj8WoFl5/7m5F2hyYonlx6EnSrMOixzCGaumnqYesyBak49 w3gg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=mBCbtxk9; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qt6-20020a170906ece600b0098759d6f22csi6107061ejb.161.2023.07.24.02.00.07; Mon, 24 Jul 2023 02:00:44 -0700 (PDT) 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=@nxp.com header.s=selector2 header.b=mBCbtxk9; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231989AbjGXI4f (ORCPT + 99 others); Mon, 24 Jul 2023 04:56:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231980AbjGXI4a (ORCPT ); Mon, 24 Jul 2023 04:56:30 -0400 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2079.outbound.protection.outlook.com [40.107.105.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36472E7 for ; Mon, 24 Jul 2023 01:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K66+sl4N8RLOtWZFcFf9C5gGeOvQYPlPVSiTzg9N547xv3NqAlCtk+/AiU5b57yx6vRgzfT5tiWvsTccvKdtgWPTMX0MHUQFN84+w/IXbCsChU6JsZkCpQFs/PkwMO/1yoTMw1ApLv4vn1zBc4db75g46vEa3KBeLhJ9fhOjKQMtRUl0VwKH6H0P8H5wC7s5edKOaXxGXxT2xaIqCLnCBJhxnl1z7lm1EmuffESw4j8MOxqIhHSoYiv4Qs069GlBNzp8FqeqZ+eLz9o65NOjFBL6gKUAoCs/IziHLMt+zIz6d0HjiqDllu1OqATuJsuxvHiFwPR0JkkoIPA7GDgyzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cp6lHxd6f22aUF5HEP9QvRTWR44J5m11pJnIh1DrzdM=; b=IAru/53aCcLQxXLkpG7ReFrE0iTlConnhqXgz//5jGYE7s5tfknmhTRDJhbrVz2XlnV74iwS6ZQ2LrfPgeU+PaK8UKkDs0ZGr3qsLxYUZ8qBaCUK5CsA3zBHydg3A4hgPuWv3rIt+BD1Zjut7ryqkMrZgn5bbYy3rx810t7LxLQv/CEydKsi860YT5ScmIQ512SivbdgAyQ3VMyp5qAIawWJIOjy9m7gwou78FIPl+uZNz1+T158UlrlbKKu7mTOOscKoLhIY0UYkqbDfMBvIHE6Zj172RmkZOniMNYte9edK6bwBU70B1dUZMfzXkfQ83IR9YvPsOH/MCEUPRI5qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cp6lHxd6f22aUF5HEP9QvRTWR44J5m11pJnIh1DrzdM=; b=mBCbtxk9Gp3YWcO5cOjgfZe4wYfSFuUnZB+Jgh/p+ZFJt5CJmbdBUUWndPNujXMKedhDBUtTrFwt4L30N+Bzxb7U2ZG2Tbzi7Q2RtTmWhOwyVrjqZ4/2soT8AqrLbu563+Mk7V5hYWpZYmy2cNEDIJh8b9i4Ap1Wk/OdOS/XHFY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB9126.eurprd04.prod.outlook.com (2603:10a6:20b:449::16) by AM9PR04MB8537.eurprd04.prod.outlook.com (2603:10a6:20b:434::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Mon, 24 Jul 2023 08:56:10 +0000 Received: from AS8PR04MB9126.eurprd04.prod.outlook.com ([fe80::273d:f528:aaa9:288]) by AS8PR04MB9126.eurprd04.prod.outlook.com ([fe80::273d:f528:aaa9:288%4]) with mapi id 15.20.6609.032; Mon, 24 Jul 2023 08:56:10 +0000 From: Nitin Jadhav To: linux-bluetooth@vger.kernel.org Cc: devyani.godbole@nxp.com, pav@iki.fi, luiz.dentz@gmail.com, sathish.narasimman@intel.com, nitin.jadhav@nxp.com Subject: [PATCH BlueZ v1 1/1] shared/vcp: Fixed the crash observed with VOCS when pairing with LE Audio TWS earbuds Date: Mon, 24 Jul 2023 11:55:30 +0300 Message-Id: <20230724085530.5555-2-nitin.jadhav@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230724085530.5555-1-nitin.jadhav@nxp.com> References: <20230724085530.5555-1-nitin.jadhav@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI1PR02CA0056.apcprd02.prod.outlook.com (2603:1096:4:1f5::7) To AS8PR04MB9126.eurprd04.prod.outlook.com (2603:10a6:20b:449::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9126:EE_|AM9PR04MB8537:EE_ X-MS-Office365-Filtering-Correlation-Id: 90c59792-0e06-4e4a-10af-08db8c23d371 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+05hJ+lc7hFDNGXvuodefy8J4QhRoHwRyfSXWLGZOSuPMPRfMcFAQOQVgfbNbwa+EEMMjafN3k9C19nSMQ42IT+MnfbCr9iRNE4W71B8JrGOs3fhjDxrJi02TO4+Fdsl5gRb/lQeNfmenb7lrn1ZkT1EvThCSqVROr6X5pB5AZSv76pdxyjmZw80xj6KvN6EaNx+TBd0SUAdOj/BpdqYL1N4T777BeUSKcZInkqn62PAr6DPxtC0fTeelei5QAJivRAdsn5gO/mpJAmjmjjqQ2jP1/4ZNSIFhaNMqO04jNg+Dr84bKydreD6WB1rup3iIMPCafrOvjILsXBRBkm+Vg6W6TFpiqWJ/3F7GMn95Txfe6rQLjeSOB6Nx48gHhltNnQuiFZzi3RRPNmEN/VBq2dciRB6mpMnmjhpzL8EFKMdQMrKuZ2pbHT4yaubH1YnQ4Qoa4w98Jf24rjQ3s6+DIGBuUzVNVaeABZB5jsGpNtkOU0TmSTHiV4p1vXXiHxVoxrANpKG4kfLypDU+tt68udrgHCqpcMI1JF6vPOpH8va340RB4llxS57MMPB3H1irp6FTU1dXYO8kLqTzGx1cQmQpwH9q20CRfYD7t8OoNiEbXTF7JMmXAKm+vyHuiQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB9126.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(86362001)(38100700002)(38350700002)(66476007)(4326008)(6916009)(478600001)(41300700001)(316002)(66946007)(5660300002)(44832011)(8676002)(8936002)(6486002)(6512007)(6666004)(2906002)(186003)(52116002)(1076003)(26005)(6506007)(66556008)(83380400001)(36756003)(55236004)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?v7Jf15vf/yNYhM86ToZY50ye0YEEBr+3i7S/5eX01J5E6eK+6jwF2Gw2jIUS?= =?us-ascii?Q?RaGpc6dRjU9vikC127QvXHlMCegD2IsG3nOe4DkI7h/ARvvQCSJa2VQG6kYk?= =?us-ascii?Q?BJuAVUwqA89e4zllMN+KdtZxK0uxLni3cEei7yTCc9Y5mkviLNOVten/dnO4?= =?us-ascii?Q?HIy7XDBJBiOV1J9QwNHPMukXboFmbkhAdOn4qyM7HJ5ybLVr+LvdMa8+eOKQ?= =?us-ascii?Q?pJSIzZrZSRJ3xEQBTYj4mLjcPXcX2k+HXXQDu/5d54mRkau3znNESdG/6aWx?= =?us-ascii?Q?dKrQxRCwqJTjOrY1uz6Qv5JHuJzT8UP/jtcBMgKBeE8LUIQ+b7GCtiPihdCP?= =?us-ascii?Q?ZiG86j5Kidj0QIR9jM/CVnNVNN3tMqrJ80vHyvb70G+/E+9ZZXgep4aI/fpe?= =?us-ascii?Q?eTRm7Bcs4QQTZpmT1exYrT03cWThaOobR3N2WfAPtU10wqwUwaDi2BimeotP?= =?us-ascii?Q?AopIPovhR2GWPS/eH/MUS1CgGgJFAREyyL5qXJldbTjAJ7rJQsZ6Bbud8tHg?= =?us-ascii?Q?ysqlg/KB2MFQlGCZyzC0/2FTkxmpM/daGmZ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eW+EZJUPvT2F8Yo1zZbyX1FcXpfc/su7sjcmW2xqaFMagMnsss7Jwy?= =?us-ascii?Q?B2EYrkhCLg6ILaN9jnJ/BnDdIOFRBGSUsoSLoZd4MVeK4Hw4uR9yecdtUZmH?= =?us-ascii?Q?pcIU31D8AuACqf6MrhYObTWRB7r4i6JD8OJISxFE?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 90c59792-0e06-4e4a-10af-08db8c23d371 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9126.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2023 08:56:10.5018 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7SYKUShL5s3LynAFaJ4pPyATmPO7+5i4Uv3+LPtO8F6WffbNaLhxZ/bXyDuGsiHk2DR7miJVvaSgeEkbq+CpZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8537 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Root cause - There are two types of database- Remote and Local (rdb and ldb). - In client mode currently the code was written to access ldb. Fix - Correcting it, to access rdb has resolved the problem in VOCS. - Same correction is done for VCS. Reported-by: Pauli Virtanen --- src/shared/vcp.c | 52 +++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/shared/vcp.c b/src/shared/vcp.c index 74bd01729..f30d7a533 100644 --- a/src/shared/vcp.c +++ b/src/shared/vcp.c @@ -973,7 +973,7 @@ static void vocs_voaodec_read(struct gatt_db_attribute *attrib, struct bt_vocs *vocs = user_data; struct iovec iov; - iov.iov_base = &vocs->vocs_ao_dec; + iov.iov_base = vocs->vocs_ao_dec; iov.iov_len = strlen(vocs->vocs_ao_dec); gatt_db_attribute_read_result(attrib, id, 0, iov.iov_base, @@ -998,10 +998,12 @@ static struct bt_vcs *vcs_new(struct gatt_db *db, struct bt_vcp_db *vdb) /* Populate DB with VCS attributes */ bt_uuid16_create(&uuid, VCS_UUID); - vcs->service = gatt_db_add_service(db, &uuid, true, 9); + + vcs->service = gatt_db_add_service(db, &uuid, true, 10); gatt_db_service_add_included(vcs->service, vdb->vocs->service); gatt_db_service_set_active(vdb->vocs->service, true); + bt_uuid16_create(&uuid, VOL_STATE_CHRC_UUID); vcs->vs = gatt_db_service_add_characteristic(vcs->service, &uuid, @@ -1385,11 +1387,12 @@ static void read_vocs_audio_location(struct bt_vcp *vcp, bool success, const uint8_t *value, uint16_t length, void *user_data) { - uint32_t *vocs_audio_loc; - struct iovec iov = { - .iov_base = (void *) value, - .iov_len = length, - }; + uint32_t vocs_audio_loc; + + if (!value) { + DBG(vcp, "Unable to get VOCS Audio Location"); + return; + } if (!success) { DBG(vcp, "Unable to read VOCS Audio Location: error 0x%02x", @@ -1397,26 +1400,25 @@ static void read_vocs_audio_location(struct bt_vcp *vcp, bool success, return; } - vocs_audio_loc = iov_pull_mem(&iov, sizeof(uint32_t)); - if (!*vocs_audio_loc) { - DBG(vcp, "Unable to get VOCS Audio Location"); - return; - } + memcpy(&vocs_audio_loc, value, length); - DBG(vcp, "VOCS Audio Loc:%x", *vocs_audio_loc); + DBG(vcp, "VOCS Audio Loc:%x", vocs_audio_loc); } - static void read_vocs_audio_descriptor(struct bt_vcp *vcp, bool success, uint8_t att_ecode, const uint8_t *value, uint16_t length, void *user_data) { char *vocs_ao_dec_r; - struct iovec iov = { - .iov_base = (void *) value, - .iov_len = length, - }; + + if (!value) { + DBG(vcp, "Unable to get VOCS Audio Descriptor"); + return; + } + + vocs_ao_dec_r = malloc(length+1); + memset(vocs_ao_dec_r, 0, length+1); if (!success) { DBG(vcp, "Unable to read VOCS Audio Descriptor: error 0x%02x", @@ -1424,13 +1426,17 @@ static void read_vocs_audio_descriptor(struct bt_vcp *vcp, bool success, return; } - vocs_ao_dec_r = iov_pull_mem(&iov, length); - if (!*vocs_ao_dec_r) { + memcpy(vocs_ao_dec_r, value, length); + + if (!vocs_ao_dec_r) { DBG(vcp, "Unable to get VOCS Audio Descriptor"); return; } - DBG(vcp, "VOCS Audio Descriptor:%s", *vocs_ao_dec_r); + DBG(vcp, "VOCS Audio Descriptor: %s", vocs_ao_dec_r); + + free(vocs_ao_dec_r); + vocs_ao_dec_r = NULL; } static void vcp_pending_destroy(void *data) @@ -1719,10 +1725,10 @@ bool bt_vcp_attach(struct bt_vcp *vcp, struct bt_gatt_client *client) return false; bt_uuid16_create(&uuid, VCS_UUID); - gatt_db_foreach_service(vcp->ldb->db, &uuid, foreach_vcs_service, vcp); + gatt_db_foreach_service(vcp->rdb->db, &uuid, foreach_vcs_service, vcp); bt_uuid16_create(&uuid, VOL_OFFSET_CS_UUID); - gatt_db_foreach_service(vcp->ldb->db, &uuid, foreach_vocs_service, vcp); + gatt_db_foreach_service(vcp->rdb->db, &uuid, foreach_vocs_service, vcp); return true; } -- 2.34.1