Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4490478rwo; Tue, 25 Jul 2023 06:58:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8uQjJjJQpO1sdJ1AaPvPdz1M6thZBRgtLDV+vIOR86YZ3eWYbkexPPqLGJd7loNkKVW2E X-Received: by 2002:a05:6512:10cc:b0:4fb:c885:425 with SMTP id k12-20020a05651210cc00b004fbc8850425mr8074133lfg.9.1690293480995; Tue, 25 Jul 2023 06:58:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690293480; cv=pass; d=google.com; s=arc-20160816; b=vrDHE1ZpGfZELQaBzeoCgB219IhcDdT+abi0xeDIIcQVgGTBsAd4Jmd6LqJXnE6Ucy VCGx/WB7oFmbGvpC3k2qVxEzZrQoE8Pg2kzlS4X4j+bSyYXQRF8pC9mVvi9jWrf7KC0O thCzJ1W/SEYV1BVzWug9TiUa7jyxWUwiJWj/cN7yyehBO5nYLH110CX4DnXSNu/epIlQ r2nqqQYxBoNk26MHquP8C640zYp6S8ro4hSpjY3ielXJpYVw+2eqjUn3FgHOAw5ua7Ya KNhGJZj+bl5noFe0IsxcWRlz5BNNukPfOWi1nuzt4SerarAKF1w6E2PR8/ybq5j5XBlb kx2A== 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=V5uPLcb3lBZSZoQkNE1JLZCYriiHEbzyU2LLLOzjBOY=; fh=O7b9e/0FHf0lC36zxfkGCP11r7lJVOROe7GJbtvFS9U=; b=VmpDpwrtZEcfbG6GitqjzTfC9DryMXoEeSj7+wBsYDvxNQwwEuf3hXnQMvlb/D9F1s XGcLhjNmPEsfpUufkwXG6cTP0l6ffWOPjtVeqyPt0R/ZAzhqgfMek7wSHaoQVK7NDLqJ 0KhRYqGqbUxXiC4Dl4KGR9JiVGu4jTLLRYsHLu+/aZhbvHoEHaRtHMONf7r7YqZe6Cy1 jD/cKstWHLU9i5GoXUPyiTrG96gQIeM6YXud7/bRBNgMQmU1llGMvCgLaawKBfRL7cjg WdIlrl2Zkqd6ysSNfx5oDT4DKNOiN2LuSVfjqSTxPxMLVmMl93svXeHlkFxTxs3B0vxw UiEA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=CrDxtKEJ; 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 s6-20020aa7d786000000b0051e242852fasi7680179edq.584.2023.07.25.06.57.37; Tue, 25 Jul 2023 06:58:00 -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=CrDxtKEJ; 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 S231483AbjGYNsU (ORCPT + 99 others); Tue, 25 Jul 2023 09:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231724AbjGYNsM (ORCPT ); Tue, 25 Jul 2023 09:48:12 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2057.outbound.protection.outlook.com [40.107.15.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E58DE0 for ; Tue, 25 Jul 2023 06:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJiaKDfG6JVGVY6fn4/VfcSoKXtKfOrcyC/wG1UWYeXHYNaEzQ7cWC2kyH8nL1OjNnTP8PJkMkV2SHdPcb9Ni5lWqKWQQygqqmks9nXucM+CMncj9J2v+xEbuP2l3AGgFBrnqvNMpfQMGPSFBZrYl8ytPgPk3oWDEpbLmeEI7da56R6VKwduNmHCTtgMKECWqOtQ0dr4vlnnetiVPMEWNOyYnll4natFnDOCioIRikCgGMUdVchj58abjWDFOZT1HPA/MOBZoDeOA0uOJTmLQAMppVLrdJJ9B8q8HfmBj828eiwP+LP31TvvKHr78zGkC9Rc4uYEXeM/LoNGt+R/zg== 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=V5uPLcb3lBZSZoQkNE1JLZCYriiHEbzyU2LLLOzjBOY=; b=gbQ60vTUD9rnEBwhWOhphr0J5248h53/DRY83rVPcPQWY4KKJ30D3atHPs3IF4XnNZIWePQWPMZJq/OtHwBJblfjinI3ugWvBGHm21nbwYfLEtJe5Wcr3JFd9MYctFqrxhSIXmvmX7++E7eKDqXnmVmCv3VUOjm+VHE7VywDf0ZBjxDKGtA2thMy/lKGiYw1kLGkekpCUh9D8MLq5IipbTnIw3PCgKCA1/LJxGD1qt0wPFlZKGQ5mr2V9rG1NBeK2twwF9bAvG1ZJaovn0QHcguLHPOi4TfsP5tONJqmCb1HowdReW5wyVODZYo0Og9pcXMJzwaLSXEqcUfaoac+ow== 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=V5uPLcb3lBZSZoQkNE1JLZCYriiHEbzyU2LLLOzjBOY=; b=CrDxtKEJ5SyMs8a6aLqOxM9YbN3aS3J7UsYaMOk/CLpcZcibJ3nYQO3O0VP29eGaQ65g/VVaMUnr5DDFDdmDsew0A/QN55e39R3le0zr6/2F7s8Yq/MBfsvytQEBe57T3UBSVpoq3Rz9voVen5xX5/nkhT7LtqIcDqlu3R29Afo= 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 PAXPR04MB9593.eurprd04.prod.outlook.com (2603:10a6:102:24f::8) 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 13:48:08 +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 13:48:08 +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 v4 2/3] shared/vcp: Fix issues of audio location and descriptor Date: Tue, 25 Jul 2023 16:47:41 +0300 Message-Id: <20230725134742.51651-3-nitin.jadhav@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725134742.51651-1-nitin.jadhav@nxp.com> References: <20230725134742.51651-1-nitin.jadhav@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: AS4P189CA0037.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::8) To AS8PR04MB9126.eurprd04.prod.outlook.com (2603:10a6:20b:449::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB9126:EE_|PAXPR04MB9593:EE_ X-MS-Office365-Filtering-Correlation-Id: e28c3f0a-9f80-4b84-db35-08db8d15c7ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /faB8oXdVDg/tFwn/N92ukWpPBdOcXhABtT1eULObB8RBlnsOkoR1JIno4yzf6G8FA5oRel2aea5n/ZOaNnoaCnD06XKoQtO8dSP8cFs4J5LKEfgMeZMpELB6FPw5GO/2ZD7HsFXWCaUfyllLhnnLKMeter/PCOFkGqMygf/n5Ydy+7wFY8/ILI6nl2vGxbj/f8kZz+593Rrw+Jmtr62CDgVhUl3bqI/qvqFBbJf/1fR9tZBsbXCEnYAdAhYThdMUz2xfwYsEAd60tevuE27hwyMh4Xxo1DnRLz5HawtfkrdAd9sS8Vgn5iUiMhXGibKGDRdzG2ggRc173AAAUSEKaQCbwagEjUepd+WdYxfJY6h29qIy/uzII5IxRKgyoaZEH4RETjn6ccvfXb/8qoxwL4kn6L58kLC/vdtHClkvAaOdRGu1UGYkrzkS6nSYkO7cY1kPFZfB0hp9wfh2ynVLxUd8N4GKcPsa+A7XiEI5tQP1AAKtZ03L5sbVWMF0/eTesOdfa1gSc0azZmbuYTP0gfN++xTO91MDGIeRqF+C/NOmVlD+/Ce/4SQ8Y8yq/IA3xeq8Zr9iNRosaydwvY5PxeE3vQ8nKEvzgk7t44sFdAskwc7IL6BTgELna9HcvQt 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(36756003)(86362001)(2906002)(52116002)(478600001)(38100700002)(38350700002)(186003)(1076003)(26005)(2616005)(6506007)(55236004)(5660300002)(8676002)(41300700001)(6666004)(6512007)(44832011)(66946007)(6486002)(66476007)(4326008)(83380400001)(316002)(66556008)(8936002)(6916009);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?VW0avO5IPglbChi8KxnZKAmK5cH4cMupA483fqdWW2pXHYxIlsJFchQ1d7Nd?= =?us-ascii?Q?iha2ped0sllX7N/M/Ar/i68DcPy7XaZorP5L1xXl347d2R0u1XRKSxWEl+qj?= =?us-ascii?Q?Qt0SvDOoacqp/rdBcxpMwpFa8Ei/jsTev1J5duwQ+8izj4SxyQp6dsTJVLqI?= =?us-ascii?Q?zYoJtQcq8oUpl18snsDNDh02F2uW8BHin/BZrjqr62XxbXP3pjZiqC/jlwjo?= =?us-ascii?Q?qQLnDpqiN51PPTwhQW6kptJOdQ8uw6TKEQULpMmncaD1bNUw+1peJPFHkMPh?= =?us-ascii?Q?sOechY/X3FvNHhVVqX/I6Q38SZ3LnGO7AmhFa8jUiQ+4EdvDaY40eejbket4?= =?us-ascii?Q?+QhZwLltDmqU5NkWC5LQMQ2I6PfvpBCNK3EfvZhXv/G8iA0r9l2j20sZJe10?= =?us-ascii?Q?9rqODf69E3UvmdtZDmxJXxecOEuvSy8f5cuvCL3thWRsZGUInjmzVUDIFJ5Z?= =?us-ascii?Q?IQ96g4rqKkbzSaRG79DXAEvFzhlhmEzehk/eaS7GAKYxL+iYMAK415yz8Dj/?= =?us-ascii?Q?f4Pz7GXwQkZql7QcUpdeujOUZR09Y8RhH77BdN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x02xNXWwx1pCjuIZlKmFrFo6IIQNbwlQ0OhDuf9FmsroF5N?= =?us-ascii?Q?o++jFLeT1FJC2N95RFIE5r/PyMWus0iF88dVv2w6vFnIp+LTbChFOTjymJfk?= =?us-ascii?Q?2xT/4Zi57wrw1wXU9c2b8P524CCp5KHei6l12W/A?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e28c3f0a-9f80-4b84-db35-08db8d15c7ae X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9126.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 13:48:08.7874 (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: qhMPz0D+kN5oNEaKQEwbdJEatsEMwGLX8+TES9SzKxZ3/FlLKd3RBfbljxbx3lPYlsWtB6VBBmvOsd0lCQPlCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9593 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 Issues - Audio output descriptor & location read functions requires code correction. - During reading audio location descriptor value was checked instead of the pointer. DBG statement wrongly accessed value to print the log that caused the crash. Fix - Corrected audio output descriptor read variable - Corrected the audio location debug printing function - Allocated the memory as a char pointer to the audio descriptor variable. - 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