Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4315264rwo; Tue, 25 Jul 2023 04:23:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlEAtO5bIsezg1Kd72Jl6FHaUOVvjnGZFexQIce/ka6tPAtzT4tP5aPraUK93dTqyQfSEmc0 X-Received: by 2002:aa7:c84c:0:b0:522:3a54:1c05 with SMTP id g12-20020aa7c84c000000b005223a541c05mr2236429edt.5.1690284201830; Tue, 25 Jul 2023 04:23:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690284201; cv=pass; d=google.com; s=arc-20160816; b=m21LOVwEOMO2mXF5teGMs1DK8NmVv+DBYEfjVBxAhytoehrLSHU+XmmTq5U6qENLE6 6rFr5nN+KdR3vJw5nBsTTKt+nn9scHY9HLrfhQZGwPT8W+YC8w/kasBOqTzzj3CHt+Pf 9LAnJi1s1Ij3Fjg2yCuQWkGaTuuOmYtuhsTRdUXf8dXIpzRYQDDfPOAZbLsuJBqF5F/5 IV2+CEhoEg2Vux3IwX3R4+2gF0OtoEz+Ro0BMhsj7zt3AbyDxE4VGp9HjbRCtUXXjf4d qH/JH2KRGuNY8HppHdfpJtzu0JKi0iz/mG2SOVvuXWbExgt1qz/vf59rIBcdoOrMSvjB lIsg== 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=hUt6FM0CMI+A9Rzv8goHZNKcELhgXs5Wx8XW4aHmQFo=; fh=O7b9e/0FHf0lC36zxfkGCP11r7lJVOROe7GJbtvFS9U=; b=TRUWTAGIr8o/hZveonD7eSAQtQ1TVLh1w9pZsD5/73EjwZti2ctSFxVFZHnOyw/FCK N5gDRKqmTCrZDRyj7GD1WmAoLXUCrgX5RiwC1MlXUL2eE+a2L72b8S+QyDJdlVzMOBi0 18XoSmJ94mmQ4uWUTgQYhb4MHHaj/xlpeEjqHwzxHlAGIKkryuUGu78SKsUSda1HAyPi PH87FaXJ+PWmStUZuzkys8qrdJ0mmFTztCX9JBx2BPmpgPcTqRGEkr+0fSJQA2SW/gs+ ZKnlFuKrnvhrlEogPRLZq27872DNGk3m9RdqoB3yKfGWR5EcmVVVuDpEkYrO8fbNNnzl 0FmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=S5BfMAAQ; 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 m24-20020aa7d358000000b005221df75dd2si4698665edr.150.2023.07.25.04.22.40; Tue, 25 Jul 2023 04:23:21 -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=S5BfMAAQ; 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 S234444AbjGYLWT (ORCPT + 99 others); Tue, 25 Jul 2023 07:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234426AbjGYLWT (ORCPT ); Tue, 25 Jul 2023 07:22:19 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2058.outbound.protection.outlook.com [40.107.8.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBFB9D for ; Tue, 25 Jul 2023 04:22:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Br5DWa8zRfiR4T9kbpXwWiVacTOyy7MFM2cUQVYqFl5hgNzyLKabfxGMXfceAaDGHVA204dumskDnHWEyzfCToxqYYJe0FfboN0VvdGZ8zhqUww/0MfFFjnCzlX8bOWLvM9HIbH259XdtRup4sJz9MhyH3obwmwUgQElYoCdWGCnuaL+1mb74U2ABhqAHMXo5f5BOB9GP5JjeP70Xw8l3jMe5rJTxIbTBEJmY88EC/DnZNqQo8HBsdzXBxsobHgD0oR6lhb1rg4YDaHGZRnp5Df5hIHdcjjUltUHzQQCEL5S52Vof+flZq+eeusKZuYmQP+CUU4vILrjZmfCK1FmEw== 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=hUt6FM0CMI+A9Rzv8goHZNKcELhgXs5Wx8XW4aHmQFo=; b=OHYmWfQSDwQVoDGRUYNvD8KBsVfbKHVdGrrNrb46iQhudzHsxG+mSzb9g8hIL+Q+oPfUjYYrLx1nZeDRp4QYi3RukjTBOarchApamBHfzntE0a6IXsIE1z0OVCW9wJCUV+HWOkq4aUxYqc45Je0JfYbvdTRx09cKCKVt+cxW7FuS3nxrWJ8nHH/M9sUBFggxlO5fzK8PjHffR4WSAmgIEpgKBUVrgvI1X3YNQ6cC1HVXw0ST7twhef/7Zi4UVjKQD5M9ogaXbv4NxXQ0VfONC91JmQNMZifUC3Hwf52PT3ouXRXjd8G2yfgpExYobcuh05uXv551t9Lb7wWMxvIm3Q== 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=hUt6FM0CMI+A9Rzv8goHZNKcELhgXs5Wx8XW4aHmQFo=; b=S5BfMAAQ79nm45WY5yn4E42rNxrmanZTaOYqvEHTtLqsPLstZqcfIEIloiSweBKzIMeN6efdyw/zBPOcwccii/3Un6L9yX33fviPfpiEH3HoV/CdstEVaptV2PsL9XOwx9TYz8i1cApq5B5POQZuCQnAX+2OuvNcfp+2Tdww0XU= 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 DBBPR04MB7580.eurprd04.prod.outlook.com (2603:10a6:10:1f7::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Tue, 25 Jul 2023 11:22:14 +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; Tue, 25 Jul 2023 11:22:14 +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 v3 2/3] shared/vcp: Fixed issues related to read audio location and descriptor Date: Tue, 25 Jul 2023 14:21:25 +0300 Message-Id: <20230725112126.49656-3-nitin.jadhav@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725112126.49656-1-nitin.jadhav@nxp.com> References: <20230725112126.49656-1-nitin.jadhav@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR01CA0185.apcprd01.prod.exchangelabs.com (2603:1096:4:189::19) To AS8PR04MB9126.eurprd04.prod.outlook.com (2603:10a6:20b:449::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9126:EE_|DBBPR04MB7580:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ed5eeb8-7cce-4ab2-1293-08db8d016563 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOv52yJFwwrKz3ob7ZQGkfhoeu5sXgjKCOCBPwi0D8TmieFtMefRcl/DIPzenPKsI6S1yNi9oAT0e0TWz+qqcfXXdCKAs+IO4d15egbMuiV5QzYAu4Z7dHrnZPx0xzwNRoRU9Yzbcv/Y60l65RICSZyd8uobh6MnTx1+wSAxwzG2cMZqo1QTY6NHEeiNA9D+njuzxszn31KaAcIAkJ83+yFsMeurg/cd+7ynW/B8+zoBVhc7U7LNQ2npZb6h77vb2vsp6tMFDHjTVPb2EDxIRNKdEYnNdCHBfHaW8v6UTPrAkVLSgAHMkzh+e9AmUiCi3p5ZgYdZ3DG2Kuz9eCF7TbCCIrWQyP5Qvc+iZKBTNWCgD3HFDSoj+UsPF5Ls92NCspv2KMA3hBj/f/o8AG7YPCrs7UyOszw90EnuQcSEp8QxoWOeiBGugSU7GehGU8cbW6NZ+YDE64B5JeicZcbsfRZqDoWRxgZ0yrlLWMdkco7N+t+Zzh8xoqYuCVsbA3pltr/NOqixi1hzjR5ZQToU5VHd9IfhsQFgRpAeRBQQdEh0IIONBMYGaSQRF8GG3grnQFAL3rMvFNX/H24/Myx5Zzx7Edvx7Gu1PSLnS6XkVrRSBnW3n0OoIyAoH2dT3pUm 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)(376002)(366004)(396003)(39860400002)(346002)(136003)(451199021)(86362001)(36756003)(2906002)(52116002)(478600001)(38100700002)(38350700002)(26005)(186003)(2616005)(1076003)(6506007)(55236004)(41300700001)(44832011)(5660300002)(6486002)(8676002)(6666004)(6512007)(8936002)(66556008)(66476007)(316002)(66946007)(4326008)(83380400001)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?hpUcDeMYSN54154iOOjhVlpMjRQPKYaJdW8nsSM38arxTNwkMKf0g/5/D9Vr?= =?us-ascii?Q?Z/kMX0cGtEdW+98aRSSAoysijB7bgTflU9p+z2yGgGmrC0C7psJ2n9Q32IyB?= =?us-ascii?Q?vIpc/zbTqRzG2lHqgEIshtFC+Erel6bIjdWy2PncH04iYHdK85Q4LXNSK3VE?= =?us-ascii?Q?ALz4upDOk88xDZygNwm40JuAwLlZdldKUkZCOfhXlO3e6VBG3/ezOuy39AIS?= =?us-ascii?Q?Sa5XBnJYDnVyZFnNOhxSiq9W+pnw/cDCyRi4jO6aZzrz3A31/jt/G9at9lfg?= =?us-ascii?Q?ruiXAzWVRfHXKMoq/fYaZBcO57O8O1yDEWgdafe3FejoWWt5dvnlzb7kNQoZ?= =?us-ascii?Q?SOYfCbf78D3Q3b9pok2PnwBkW21fxlfh56wl0E8610bIqYGZHHjnuXAf2KaC?= =?us-ascii?Q?rLBLfnccJ7ziPxWWIBYuBCyORBvzTI3gVn080pL2WrhRz+ef7hbKnabuTVdl?= =?us-ascii?Q?K8rqG1V/zZn3K2RlDOerRArfc0k6TKll5t0Otl5sNqo2R5iIkS/MNes8B9pN?= =?us-ascii?Q?bmQ0NmiaLAz2T88m0H76nE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-ascii?Q?ncO2YJW1g0YgZL/3s5/FN/kxOCZmO9VNossgLNkHb/gFCbTm2VYvaMcmbhD2?= =?us-ascii?Q?ZhNY80Ad/fyOwOR/BBLMAq/FjI8VafMUVNist01BPEWoyT4OvWDYyUJTDQ3B?= =?us-ascii?Q?zj80E/SMTaq0mDQesG22QRcfn23qv8e2snRSrZrd?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ed5eeb8-7cce-4ab2-1293-08db8d016563 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9126.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 11:22:13.9425 (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: UEJET26YjuHWFR0SJ9SzN/Lx/32HqkW78Panvj0Ttbe3JYlp9F3EU54vbpseseFQGBvNX/pmtrAMQ13aXrT26Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7580 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, URIBL_BLOCKED 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 Issue - Audio output descriptor & location read functions, requires code correction - During reading audio location descriptor value was checked instead of pointer. DBG statement wrongly accessed value to print the log that caused crash. Fix - Corrected audio output descriptor read variable - Corrected the audio location debug printing function - Allocated the memory as char pointer to the audio descriptor variable and copied the string to be displayed. - Corrected the audio descriptor pointer checking condition --- src/shared/vcp.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/shared/vcp.c b/src/shared/vcp.c index 314618664..0408531b2 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, @@ -1385,11 +1385,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,13 +1398,9 @@ 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); } @@ -1413,10 +1410,11 @@ static void read_vocs_audio_descriptor(struct bt_vcp *vcp, bool success, 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 Location"); + return; + } if (!success) { DBG(vcp, "Unable to read VOCS Audio Descriptor: error 0x%02x", @@ -1424,13 +1422,18 @@ 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) { + vocs_ao_dec_r = malloc(length+1); + memset(vocs_ao_dec_r, 0, length+1); + 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) -- 2.34.1