From patchwork Sat Nov 5 06:00:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 622709 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 2ECC9C43219 for ; Sat, 5 Nov 2022 06:01:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbiKEGBq (ORCPT ); Sat, 5 Nov 2022 02:01:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbiKEGBe (ORCPT ); Sat, 5 Nov 2022 02:01:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01CE83121C; Fri, 4 Nov 2022 23:01:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F40F5B830C6; Sat, 5 Nov 2022 06:01:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A421FC43141; Sat, 5 Nov 2022 06:01:28 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1orCFg-007OkS-2j; Sat, 05 Nov 2022 02:01:56 -0400 Message-ID: <20221105060156.686027537@goodmis.org> User-Agent: quilt/0.66 Date: Sat, 05 Nov 2022 02:00:34 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Linus Torvalds , Thomas Gleixner , Stephen Boyd , Guenter Roeck , Anna-Maria Gleixner , Andrew Morton , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org Subject: [PATCH v4a 10/38] timers: Bluetooth: Use timer_shutdown_sync() before freeing timer References: <20221105060024.598488967@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: "Steven Rostedt (Google)" Before a timer is freed, timer_shutdown_sync() must be called. In h5_close(), the timer is removed with del_timer_sync(), but it is only freed if hu->serdev is NULL. I added timer_shutdown_sync() just before it is freed. timer_shutdown() may also be used, but just in case it gets re-armed somehow, I figured another sync will keep that from being an issue. Link: https://lore.kernel.org/all/20221104054053.431922658@goodmis.org/ Cc: Marcel Holtmann Cc: Johan Hedberg Cc: Luiz Augusto von Dentz Cc: linux-bluetooth@vger.kernel.org Signed-off-by: Steven Rostedt (Google) --- drivers/bluetooth/hci_bcsp.c | 2 +- drivers/bluetooth/hci_h5.c | 4 +++- drivers/bluetooth/hci_qca.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index cf4a56095817..834b2efaa9bf 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c @@ -737,7 +737,7 @@ static int bcsp_close(struct hci_uart *hu) { struct bcsp_struct *bcsp = hu->priv; - del_timer_sync(&bcsp->tbcsp); + timer_shutdown_sync(&bcsp->tbcsp); hu->priv = NULL; diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index c5a0409ef84f..633f3027abd2 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -265,8 +265,10 @@ static int h5_close(struct hci_uart *hu) if (h5->vnd && h5->vnd->close) h5->vnd->close(h5); - if (!hu->serdev) + if (!hu->serdev) { + timer_shutdown_sync(&h5->timer); kfree(h5); + } return 0; } diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index 8df11016fd51..eb81296b284c 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -697,8 +697,8 @@ static int qca_close(struct hci_uart *hu) skb_queue_purge(&qca->txq); skb_queue_purge(&qca->rx_memdump_q); destroy_workqueue(qca->workqueue); - del_timer_sync(&qca->tx_idle_timer); - del_timer_sync(&qca->wake_retrans_timer); + timer_shutdown_sync(&qca->tx_idle_timer); + timer_shutdown_sync(&qca->wake_retrans_timer); qca->hu = NULL; kfree_skb(qca->rx_skb);