From patchwork Thu Mar 7 13:58:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 778929 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2051.outbound.protection.outlook.com [40.107.15.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7E3112D753 for ; Thu, 7 Mar 2024 13:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819930; cv=fail; b=aIrLMHI1v2gd63t8w1zi7chiz0+HDapZSloJNcLYvHe8eDjZ9eOjNI4cgJd4eHumDOwY78YHKl96bu325YqqXsc/H6NN5Qr3dzTF3ZWQjQwyVBLtTSPtpGgOyehjEc33MWR+Dnw2Jki/0NBPuvZa76dn3HUNXuuLNmJQ+9Gy2MU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819930; c=relaxed/simple; bh=l3toDbqNW2xamIbZoj3+YPaIimhqeZKUU+emtR0vZqM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mUH7SDaCLtcacVjaMs77ky7Y3PgXWp4QHVHYxGnAWqc7S6zjAo5Bb7EC6lQ16FoiesWVv3vw0nmNAWeQx8nYih1MtF9ICXT3AOv8FDqMHXn7jkpNfvzAb7UJ/7uK1t5CYPqbnD9WMTG0KvGtB8byUt+JhPcz8pEp3JUe/23mH3E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=YeUgyPp4; arc=fail smtp.client-ip=40.107.15.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="YeUgyPp4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6ua0K/GYXCUm/Eh3foltSp9e57FSJQraHwwGk9uzFEVsMdveO480eO7yefqAztaq/v6Y9X8KXWQIu87a/w+mGYFL35kFq6iHLwsli9b+KRYnrTXRriDqye5h7ikl6L8fXDeenJRqZ/pz8ADG7PTNwz4TmoFGSreef0o8OaSfnzQhi4WVkZLw1PxvpYYFAUkHoIhQFi3k9HH2FTxaaRM9Wf8q1khhVkqChGOtWqnUKKvvELYUDjNQ5lUwpw8aAHGhh1SMPk9wiASa3hUpeIgIVQKskEUsdeNKQhAt5wCSP58hSyZO1wJNKjkKGG0aylKxfGwwVwxlCDBbY9lEGGl4w== 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=UTLlvV3lDAfHLtQMNVrPDzNZKrtubuWYnZIqo/ddJeQ=; b=hh7MF5LTN+H3Nvntfddo1yJgHzSzBnpQnFqLDb5wtEw4GFSIUB+BVF/AjgWxznxbsFjpf/Tss1pCwBNbmwFNTUq5dpkdd5dDQC8RjqNxpaixilalJh7+TajLIfUwC8EnbF8QbOy2lQQrIx6N+oMbMHM5Xet9gC0vPj3xfiANTxZXM82AOp35+zTTWGSBLV3aAHRwLomwY1H3U3TeH2d7XZ6M1kOV8+bHg9uuZecm0fwQUZ94d7jpMkgrRoyr+RX8Im6wUKISwt40x0BHyIsQxIBO6+8fkSUJ4F5aQL10XLvc8lh+CCRo1RcKm/U0PMq4vEAkWXP5WJrmrlwY3yDVCQ== 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=UTLlvV3lDAfHLtQMNVrPDzNZKrtubuWYnZIqo/ddJeQ=; b=YeUgyPp41svztuUC/pPPO1P+8HjV99xCSlZ0aoly890y53ZiLPHP5c/9QZGeTtheeS7Sp8haut5gOW3sf6CynxJOtbE22imhLprHAlHoB3FqInAr78sPnR8t0MSxC8Ihn+uFL6uSLaHFGdmvZfqYbGQ3PO6S7UIL5YA0q6mRewI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8909.eurprd04.prod.outlook.com (2603:10a6:102:20c::19) by AM9PR04MB8424.eurprd04.prod.outlook.com (2603:10a6:20b:3b5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Thu, 7 Mar 2024 13:58:46 +0000 Received: from PAXPR04MB8909.eurprd04.prod.outlook.com ([fe80::ecae:646f:ba80:b0f2]) by PAXPR04MB8909.eurprd04.prod.outlook.com ([fe80::ecae:646f:ba80:b0f2%6]) with mapi id 15.20.7339.035; Thu, 7 Mar 2024 13:58:46 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH v3 1/2] Bluetooth: ISO: Fix circular locking dependency warning Date: Thu, 7 Mar 2024 15:58:33 +0200 Message-Id: <20240307135834.3941-2-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240307135834.3941-1-iulia.tanasescu@nxp.com> References: <20240307135834.3941-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0027.eurprd03.prod.outlook.com (2603:10a6:803:118::16) To PAXPR04MB8909.eurprd04.prod.outlook.com (2603:10a6:102:20c::19) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8909:EE_|AM9PR04MB8424:EE_ X-MS-Office365-Filtering-Correlation-Id: f46b422d-58a6-43af-2873-08dc3eaeb4e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VWy3eksVtQh3DF/2p08Ba6u1DxYOkhCGgOEAMIwvrTg0TDKzlLdkCWaqfyY9p0uBgt1/26HEqROyggCErj7uvvDoHCBtcGS1raQCaBYz1MDq95NZZaTIRgRJma0Xyk4VwKyjHPdaLruWrmoeNh89rBa1TeIwJPBQRKqAnRA0SHmBSDtjYyggCV78tLxdBCozIfO2R56MiHvz5RTcrA0Og8bLMZzDkeZu+BPxzaGzfYXocbSOcwD/bpfTbrLYYaaT/iob/y+zTXUr2TcJBjiEmljC40TrGBbHVKS5xG15LUMTV02BuYTcilVGaZ1jpnGLrJUa2lRnlOjb3QLMmH46blUtwTgVStAGb3r2v1sS7lyLcNtUDY8F/eAR4Z2GKBftcyOyMuQ0vHRKZFVg+/wanhCll0VXRmW/Q9lkos88wvtHBapUyuUDZVpEt/DkRohnj405t91sVOL2DcH+LYcpmn3DCASFLS5BzUCOybaqJsAArl4CFDfreIriJ6AQiCe1Zm0J1M5q8gpqqKQVoee9o9bbqdOGKPsFJe+TTW8wU9XUBANk+q/+R5DYvSnH7yqAMfqwqByAHKU+6G2k2aBVhuEBrgA00dCX7tj0c3e3d7SEfaD5xK5t0bWrMbUr+xALwszkEOD2tXd+/+Apa7+mE6toiwMKcrvRac40+VQ9Q5Q= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8909.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S22DAvdmnvVGkrr9HJsoMTBBHU+KF3kzESVW6hDNqs6q74wOnXjqOPuyV5nqYglfVg3EnRw182Qcr9qfQ1SZv+EyLKhqe9tQTW9O6TC/aNqKyV1z5UI+h3Z4Lg6C5ZD3MIUHQyXZJtm4aVBXp0U6ulcQyLuNtwoi2yWodlnR4Lo7RTYxFplS9udLEFnMxY7oHmjc5ZuJ9++yGozwk5+k0KZCYVc2LT9E5eO5mXDE/h9qt/mcWqDCTTA8GOzuEcpWlQ2LnMzUf566bhHuy191vnGHH9gJdV6BXFCfb6Y7rEvNl+vu+j8hYEDaup4YNPuci+zXgppV+dnl2E3MFsSyLvtlPWonal//B/dUNve9ZnbE1wRbjDlNljnGG4Cl+K3xEkwIYtP9EJEAJIiI7arWkabq88QxkA9jQL1FN8VrL1rGQbtBnbn2KjIMcbFLWJwmdUejvwUFqw92LezxlpL3FynXO+tGe2yAYE3SHtCpxo/oAlN+pEQpDKY9w5zobG6v6LN3iOauoQJeBMVpHXCyS5wTGYAKH4DtIp/inooMjSIKUmCwx+frGRcqX8NycRNS8e7tFo1Y+9WrN8Ok0EV0GBnTjd6Z0I0XcxhE0/H623gHO+4Q73ZMf6Z7ijx5tWIWsUER0g2+2pMybmqvBlrrZWUbNr2Ma3tRsWWK4/9vAjWPuLKrPe6JFqjaFdR9BEpL02Z/4Y1iOFhH9C8T59WPAdraZhYm2uOYE2Ygttpen9aIG1REw46u8BhkLC2boRou1Zqw4ZvZG0mOUoH6nbcJE4TyWh7kScYYPsaWUGTdDWrb+oNAMnYMqihjGttRm9lbY+jEYQSF32llIJ7g5lcpmgWq3BtcQT87Ph+z9PXONJE1i2C63DyAilu8MWnpE65dUPGxlWQsrfIj7d5WtfxqI90FVA/7/JPK6+zhUDVdODBaGxs33xggRPvl2p4z9oYFRLObucfRt2Bo+ap7TPoczGZvNEaANYA2hG9IyDQbmP1IFA8MnJf1AI01nEh68OQ1NOKbRRr34Ad91AFwID84dKV+BwBbUkhOOoWYRAy0mNqjd3FpC1L1G10y0ALHOKMl5TS6iiTjo53Si1VSunQ0oJp9qXv5h7VBpE6XOe4KM9kuUrxXTJjVLHrK+wiq9z+o7xv0RhuBbf4bkKjxd39dGj4dvciNfmh8IOEwY62vWFhwMqJKosmZyp3rsELXy/f1Bvh8prXvzJwl4fv9ujyMOHfKqZGc5ZXqWDjkSYwKAmNVmw8Tu8lEb/tYRnGuv7aDhYtRg3hOBGOURQ4P0DMrXCKZCsUguRYOK+Vi8OdqTFBB32DiwTezKYN/d98uGUbvHeT/jAjVSQzvWe1RXtFoBPVfNebjfzYIms20hCfO461miuYqw6UFkK+Qve6me0P8AobBUJj0JpA1mBeGlxprhyK7h6eKL/DR6hBa85GTXcCoS6EsBc2LV8z6sy/IGzTEm20s0J6+WIaVZGTXRwzQMRLMVW8GgW4xlofCbbUssukogRvo+v00tD4q7SZiBgPFh4H0DKlHU6NAmeNl6tmTAL9JDGVV3jtsH8aYt2qL9VuluMhVPsu4n5cuoXNkuhhO9nXMSvlyTupDBCqIy9GN4A== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f46b422d-58a6-43af-2873-08dc3eaeb4e6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8909.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 13:58:46.0903 (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: XhjukVzflwDaummlBskzEPOJW0dWhwikFFC61P6X7n/HBUauNL9Ud1Z4WoBzqJskjqnNXEXchyvSl5ggxmceyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8424 This fixes the circular locking dependency warning caused by iso_listen_bis acquiring the hdev lock while the socket has been locked in the caller function. ====================================================== WARNING: possible circular locking dependency detected 6.8.0-rc5+ #1 Not tainted ------------------------------------------------------ iso-tester/2950 is trying to acquire lock: ffff88817a048080 (&hdev->lock){+.+.}-{3:3}, at: iso_sock_listen+0x305/0x8d0 but task is already holding lock: ffff888197c39278 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}, at: iso_sock_listen+0x91/0x8d0 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}: lock_sock_nested+0x3b/0xb0 iso_connect_cis+0x185/0x540 iso_sock_connect+0x445/0x7e0 __sys_connect_file+0xd5/0x100 __sys_connect+0x11e/0x150 __x64_sys_connect+0x42/0x60 do_syscall_64+0x8d/0x150 entry_SYSCALL_64_after_hwframe+0x6e/0x76 -> #0 (&hdev->lock){+.+.}-{3:3}: __lock_acquire+0x208f/0x3720 lock_acquire+0x16d/0x3f0 __mutex_lock+0x155/0x1310 mutex_lock_nested+0x1b/0x30 iso_sock_listen+0x305/0x8d0 __sys_listen+0x106/0x190 __x64_sys_listen+0x30/0x40 do_syscall_64+0x8d/0x150 entry_SYSCALL_64_after_hwframe+0x6e/0x76 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(sk_lock-AF_BLUETOOTH-BTPROTO_ISO); lock(&hdev->lock); lock(sk_lock-AF_BLUETOOTH-BTPROTO_ISO); lock(&hdev->lock); *** DEADLOCK *** 1 lock held by iso-tester/2950: 0: ffff888197c39278 (sk_lock-AF_BLUETOOTH-BTPROTO_ISO){+.+.}-{0:0}, at: iso_sock_listen+0x91/0x8d0 Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index 8af75d37b14c..d1608387fd85 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1069,6 +1069,7 @@ static int iso_sock_connect(struct socket *sock, struct sockaddr *addr, return err; } +/* This function requires the caller to hold sk lock */ static int iso_listen_bis(struct sock *sk) { struct hci_dev *hdev; @@ -1095,7 +1096,15 @@ static int iso_listen_bis(struct sock *sk) if (!hdev) return -EHOSTUNREACH; + /* Prevent sk from being freed whilst unlocked */ + sock_hold(sk); + + /* To avoid circular locking dependencies, + * hdev should be locked first before sk. + */ + release_sock(sk); hci_dev_lock(hdev); + lock_sock(sk); /* Fail if user set invalid QoS */ if (iso_pi(sk)->qos_user_set && !check_bcast_qos(&iso_pi(sk)->qos)) { @@ -1128,7 +1137,13 @@ static int iso_listen_bis(struct sock *sk) hci_dev_put(hdev); unlock: + /* Unlock order should be in reverse from lock order. */ + release_sock(sk); hci_dev_unlock(hdev); + lock_sock(sk); + + sock_put(sk); + return err; } From patchwork Thu Mar 7 13:58:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iulia Tanasescu X-Patchwork-Id: 778633 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2041.outbound.protection.outlook.com [40.107.15.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8004812D753 for ; Thu, 7 Mar 2024 13:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819934; cv=fail; b=MBA6IkMvSWG3Dy2IbE89bk2hUFhNx0djFNKBuKAvvvW+rU4fVRhKios3Lf7ZDJ4hXphe+yYOtQ1K0Cu/AkjEPBtiCDLqqDYjHUB535Ntp4gezFqDhJaGaC60VPYhHmBYu6sGSspTEltni/U7Aqstx2WGFwq3VVQ1xjzvTUtPTX4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709819934; c=relaxed/simple; bh=6MR6+EgBvKVOIu6+SXwdbd09yF1yIjnGCSb+RgesRHg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=AXegA/PHzk+MZAJZKL6K3EezsbZOihLBNrGHxMyU9bR4Qrl/KbsKYSRDybN9u98z4f4R7+JRORVanzOzsgOWT/qzZKLuxW4jRlhMSY7dOAdFsoikA1izkHnLHBqIkz0yQIT+0qAxq1+IlapHZubHfesYyF+8e5y76FLgA6d6yLk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=NvINnYxt; arc=fail smtp.client-ip=40.107.15.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="NvINnYxt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cp6NVYCdYE/6cCeGb9xQ/v2rhVsZYCFWsAnJPCALhyyaz/2htCxvrdgvZ/QqyvoVBChL7TO44B1PsFZXcui2mRItLmqeiw1YERDGgt0sZFHB3qnfehparTKNhLOo7bBIvRXaWGkPsK2X219MEFipL0wojq++1FsaBSQj3FIhIiA6wzJc58f22tnRdn76jf1Y3Fd5Xz0rfz7APOBzi14gaNtPq1oc9OPRrKR7KAmjuXWIDIOhwAIaKlHlDv+nqpM3RVywHroTQpFA6+Au2EkyHG91EfRImCy8sU/iY+HUYAfbZDWHAUJ8uxuAecyVHJdELU0keKpK81c2ZwfPyNSC6g== 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=ciLkxyUn7Fu2cMas7kn72dWiO4fEzMz3n5UpZnccKeA=; b=odxl4Y7fW4XQtr04sr9WAcGT21q4ihBAFFja6DsWSyCzLY4U97i4rEMPx/DM918I3jmtygaVRLty9CSNW0I/rnptazul4NgG5eEXv9eHT50Tn+1Y//jGRmSpvyW2wd9PD0gUN36IpxwvsPfLNMTO4pMVw8mXYakjhYCR1d87BLsJ1mOzhBXPtdNWP3yUlMnOkfxUnzKDArJljb2ijTb1FJnhJVttAIif/GAK1g9kBSoB/ehNcmnQwG9RNDPXmC+FKzdp360jKvVmiGatxWOqCvkmnsBM212HLCdVIT4ETeSHuq/PZOa8mkPM5Lswwga+f+YydgO0DOXR1Jp0Ozkw0A== 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=ciLkxyUn7Fu2cMas7kn72dWiO4fEzMz3n5UpZnccKeA=; b=NvINnYxtYZaRzR5CS5DxawXMmOptnd8TJRdrOrU10XJN2SgLHbxolY7i6g8FDCitI4cnLpVl5n64nfuJGWqt6K9nuxxPJqe0FI46+5/UdoADQIUCXiM622/ypNV8XW13edVomrUaoiFdNjrCdFpKlme55RJU5oah4LxW++w9QCk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8909.eurprd04.prod.outlook.com (2603:10a6:102:20c::19) by AM9PR04MB8424.eurprd04.prod.outlook.com (2603:10a6:20b:3b5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Thu, 7 Mar 2024 13:58:50 +0000 Received: from PAXPR04MB8909.eurprd04.prod.outlook.com ([fe80::ecae:646f:ba80:b0f2]) by PAXPR04MB8909.eurprd04.prod.outlook.com ([fe80::ecae:646f:ba80:b0f2%6]) with mapi id 15.20.7339.035; Thu, 7 Mar 2024 13:58:50 +0000 From: Iulia Tanasescu To: linux-bluetooth@vger.kernel.org Cc: claudia.rosu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, luiz.dentz@gmail.com, Iulia Tanasescu Subject: [PATCH v3 2/2] Bluetooth: ISO: Always release hdev at the end of iso_listen_bis Date: Thu, 7 Mar 2024 15:58:34 +0200 Message-Id: <20240307135834.3941-3-iulia.tanasescu@nxp.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240307135834.3941-1-iulia.tanasescu@nxp.com> References: <20240307135834.3941-1-iulia.tanasescu@nxp.com> X-ClientProxiedBy: VE1PR03CA0036.eurprd03.prod.outlook.com (2603:10a6:803:118::25) To PAXPR04MB8909.eurprd04.prod.outlook.com (2603:10a6:102:20c::19) Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8909:EE_|AM9PR04MB8424:EE_ X-MS-Office365-Filtering-Correlation-Id: 86899e51-98f7-4c46-90f1-08dc3eaeb74e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jYjS0RKeJ7ly87dJleSpqnLqyQDTWYbm5sqGKJJq46QK+Lyc4Ygk1UZIXaZs1v08uhCRbmzaP69ttF123/8hBCWA8qOGXOWt6kCodsJRyHU0oopWh2v70SZ4DZcri0UYEPHh9cF99pETPrGxEWIvoBUYNmg8izt2HvqRrfvjtYJE1UMO2gTPAUsAOswOFWEH7P++H8QeLZay2Xl7uV04m6TBCuBDIhpWTdkb9sB6xZjxwVqnChAetUSMBFIPYOfW846+tlb0OYfEd/fV3W3wgonHVmjr7ouT+HNVKIK3icEGtnLMgIK7vRqYZ7SfwBmyQA1tEKq4iLE/tfrBL2oNeUCBDkOVwGNW/mnIVUj4Q/ZyNfMIn4HQWLqFlGAY6UfQGO/AESJCceyICq2fhNkF2kudC8HGBi0yGcH+t8VuF4i2jp/fgGZoiQH8WibUgJpi+AFCBjOwkwP9kYR9DmjmHt6Mf9KEKxBEM2YD84VWctMR5eAzEB6YBct631hYUPTU63yTWQYCHMBDRR59CwW4R2V012NbGc9hlRktM14n3DyWhAlH+/2fXSs5KMaW4rzOe8axZYKy4q+iuFgwx/nbyHSfO6mZ6H9+9JE3nCrOt3i8FFW4HDj/DJ9KQGBvX5RBNFMF92fW9IBmiTIEpNiNKQc3XsKklB6lUXFgjMeqq5s= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8909.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mUCmvlSudjVklL8qPnI6qgCYluqSvBBVi9y+XeOv709nqm5gx1FGRyJWSmfhmn5snOZRAz2WHCjFFpoPiRR4q76W5lxGs/tpZHhsuvb+5gMh8Nymyl5IfNI+b1sGNFx4VDoKX0lY5NKYAKKqprwsQNOkGlZbm40bHnngd5oZ+xXGBXkzeHGIlqAF8eCkW6fzzNhbtHF0iZ1Ec71DnaN6Q/jHSYhwEHJhWb6UWKd6oSWB2BIJVFUDL7y5tk11rtLpkB8MF2IWp4yMGe4d5y1bXmFoha/mcQq7Vyckbod8wbAFMpgF3d5G4YQ7BGkeb3Z+RhS2jpC8WrvBaZlP1GJ3hh6diJZce8jYHLi3sGVImSg3mdKH23vO63CqAOqTrTb2aWMHrvVRhRInsmn0xLjRDOHNVMYQ87pzjgKSStJTkq03l7ZLxa5uz5GxZHNra4kqf+gSbk/D8q4+4O7xJGJaLEAyd4PC4EhEsrTrr6vyxYjqEvYLUhYvZKa/uPo1h+jas+GpeBapjCb5wD/dXNqJgSLuYww/XF5uV2RDID9s9cB6b4+EkvJ+riBnr1/E1bRDx9MQRMotLz+pSc2Oo0fmglG6aWq6YV6uYXFZxex0/ZqsLs3eKsTkoP48ZhpXLNEzvWlZwYQpIN+GrtsnMZrNmXFo+FbkyZ36gGwgnx9meg6TEQcP38n8yGAmlWe+kcODmR8ic7/s2Vr63T089yj3ABgd4rn/Igx+piktB64S6zmj6VPtLbVJen9OlKORTnBUw+InT51tQamRPTKxDGUoyCjnUVBuRu6WXJl06lTWwpN/QAD7bu0XWb971nGcT5M1wEVR58+Q055xtJk/WJ2RwZac/KG8Ua9YtgofRHG+KtdzPc46JOlwrrrIY+hlgZQEOWJiCvLboXwW+siVFua0Qm1izb+7TqKa9k3eeQK9lWXVgaCOr9LY84I0U2CjppD3mh8GOJuEINEoM2wgsLtyhgbR95KzLaBuCOHDeLWAKfqXSTr1QzArZJWpweaCKT4PQ0m/lMAervA77hhgrZl/jj2btkNb9YIkd4ke5bsOhhpdIQZQsTO/5rUV2nI+kC+sHg8okxBAGdcxH3sxiPy2bxEP7jKFq5h/+SXx0o+wM0gBZUFW1LA2vVb0oeqC8p/eXAK9uZvE4rqHp5V24vfSs2CvkzDxV9Eb7kcYecfd3OezZH/S1MLgO4ZXA4xTqiZ24GpFWgqmFJn7jLyhdShhC0G/vDeqoz0PbXNXIHWQVmAfLRIeCqKbi93ej6xeqB2lntqNMCFDbv6ORsrxwr9JrZEyjBbpvHiDWwtJ7o9W2q3WAGvLGcPSoge1YjeatLf+nBp3jqpjBhdfejJfndFc8sVoy9Jx5SP/eiPr6Z9AQBrt6LtpphKIlAkvo7+0VHhyeQlOMFiDzvjzhg/zu/JKQmXei2WRHbl5+ZiyKPCxFR9CWD0xfFnmjpS48Pkq+3b4lbk6h5CGleAeeldaB6vdKih40vZwlEhrkQhrI/OgqaWy0GNat4M9ZJRRPpwLmyxuTO5AISqPxJyb8fx71Dg3kNOiTq6EHSXc00MkD2YpUgGp8cmIKa4B0aSvnQg7LwQEymtOzwX0LPiyt5WTkhdJZQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86899e51-98f7-4c46-90f1-08dc3eaeb74e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8909.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 13:58:50.1347 (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: a2j2Qp0Nnl7TiBJzSVh+yWipbcKQVOfTOVRrazMdrC17R8sT+6YYGGbnMcB/tDsHP1Dko6R4yer9iS0syfv13g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8424 Since hci_get_route holds the device before returning, the hdev should be released with hci_dev_put at the end of iso_listen_bis even if the function returns with an error. Signed-off-by: Iulia Tanasescu --- net/bluetooth/iso.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c index d1608387fd85..bd2271cba359 100644 --- a/net/bluetooth/iso.c +++ b/net/bluetooth/iso.c @@ -1134,14 +1134,14 @@ static int iso_listen_bis(struct sock *sk) goto unlock; } - hci_dev_put(hdev); - unlock: /* Unlock order should be in reverse from lock order. */ release_sock(sk); hci_dev_unlock(hdev); lock_sock(sk); + hci_dev_put(hdev); + sock_put(sk); return err;