From patchwork Mon Dec 5 15:09:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 631124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B05BC4321E for ; Mon, 5 Dec 2022 15:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230100AbiLEPMD (ORCPT ); Mon, 5 Dec 2022 10:12:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231934AbiLEPMB (ORCPT ); Mon, 5 Dec 2022 10:12:01 -0500 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9C602DE6 for ; Mon, 5 Dec 2022 07:11:59 -0800 (PST) Received: from dggpemm500007.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NQn7M4rjCz15N6V; Mon, 5 Dec 2022 23:11:11 +0800 (CST) Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 5 Dec 2022 23:11:58 +0800 From: Yang Yingliang To: , , CC: , Subject: [PATCH 3/6] Bluetooth: hci_h5: don't call kfree_skb() under spin_lock_irqsave() Date: Mon, 5 Dec 2022 23:09:25 +0800 Message-ID: <20221205150928.4017973-4-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221205150928.4017973-1-yangyingliang@huawei.com> References: <20221205150928.4017973-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org It is not allowed to call kfree_skb() from hardware interrupt context or with interrupts being disabled. So add all skb to a free list, then free them after spin_unlock_irqrestore() at once. Fixes: 43eb12d78960 ("Bluetooth: Fix/implement Three-wire reliable packet sending") Signed-off-by: Yang Yingliang --- drivers/bluetooth/hci_h5.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index c5a0409ef84f..2b97296abb88 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -283,11 +283,13 @@ static int h5_setup(struct hci_uart *hu) static void h5_pkt_cull(struct h5 *h5) { + struct sk_buff_head free_list; struct sk_buff *skb, *tmp; unsigned long flags; int i, to_remove; u8 seq; + skb_queue_head_init(&free_list); spin_lock_irqsave(&h5->unack.lock, flags); to_remove = skb_queue_len(&h5->unack); @@ -313,7 +315,7 @@ static void h5_pkt_cull(struct h5 *h5) break; __skb_unlink(skb, &h5->unack); - kfree_skb(skb); + __skb_queue_tail(&free_list, skb); } if (skb_queue_empty(&h5->unack)) @@ -321,6 +323,8 @@ static void h5_pkt_cull(struct h5 *h5) unlock: spin_unlock_irqrestore(&h5->unack.lock, flags); + + __skb_queue_purge(&free_list); } static void h5_handle_internal_rx(struct hci_uart *hu)