Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp370908ybh; Mon, 20 Jul 2020 19:38:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/j01q1VUR0I7jQ//eZJeMWLFHkvlbEMzwNetaWaDxT0XSHWrdya6F4Z4YFq7Awn1Bs8RL X-Received: by 2002:a50:ee07:: with SMTP id g7mr24779844eds.320.1595299100574; Mon, 20 Jul 2020 19:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595299100; cv=none; d=google.com; s=arc-20160816; b=jO8JdQcKH3+DD8JuhE/FZ9gujlAaQxqDjxuR7IkUM06QhWUHcf7oJDKavorkWGY4Eh lIw8FbM40VhDIdLmVGYXym2u7Pf96G40sEk5ORXk26pzV1C/mdOTvJ80jWpO2c2h44MB UvFIw++r0nb9zPZqUwBofSJNMOInDvoUE+LDQ2qZzegasMFXovocCH2V2PUl6IJELvW8 BfroQQ4bP98agdU8sxR6b7Vg9yMdLPty83EATBxYE+kIsWh9wAiGxnKdvX92ZsrMov7g 5MfxLIv026sUXEn4JGt7uwVkFausZAy3HnOIKJ1OmmFcJi9Ct1T21T/UJ7aFNyrVWs4L MyfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TY8XfCON4S0JDepfGrFgWfYRJOwnBuFe9fcLJ+y+GUE=; b=eTM0Jip9CZR4bN2PpsheJJ4iPe+bRXhxXQgPA7KbIIh7AXoBR9fAVPjzowPbUg2hV/ 0WlFY8ppnG/5EylEkvMXVScVU/4tPI7rGniOHD2krDHeWH917vkkjh8KX/dZH45dYMtk MM/N7t5I8DrhIyx8ooi2pQe+Qidst9plDvtdfZrcnoNDRt6zh5mflq8e+KNclRlXubBQ NItAOYRAKMNrbQqQrV23LOsiUw4KEslS0ePLYKvMEmvKqa4XmeAiuqsczFkuh2Xr+gjy 15VhlRHnXTpWNNjm+efysRTCFypbu9KkhVSX/StbqmcnJEjDqKKoj3QRYz7K2EjxNPy6 7iuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MT9XwQvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x65si11273811ede.585.2020.07.20.19.37.58; Mon, 20 Jul 2020 19:38:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MT9XwQvk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbgGUChh (ORCPT + 99 others); Mon, 20 Jul 2020 22:37:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728117AbgGUChg (ORCPT ); Mon, 20 Jul 2020 22:37:36 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D18BC061794 for ; Mon, 20 Jul 2020 19:37:36 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id l6so9579933plt.7 for ; Mon, 20 Jul 2020 19:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TY8XfCON4S0JDepfGrFgWfYRJOwnBuFe9fcLJ+y+GUE=; b=MT9XwQvk7j9jaVTNDu33PSB3paK7rMOToCBADL8lAhj8gfTegZZY0dRfXMdKpbwIsl WT2qUkCmWI5WetdDngau1iznOVAqPUFe3M1Pbnsy34yKF3EDeLkJcL1uG1E1EZs5d1jr 6GJgb8m8HGh1IC//kNuLNntIXuRVewVb4EtGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TY8XfCON4S0JDepfGrFgWfYRJOwnBuFe9fcLJ+y+GUE=; b=fEaZvDVwMuDOi8bCUzdY0Zu+7r20cOrTK0awH2iDwPaCBJMdsZ5ETgnTHLzvKvkktv E0QyLnmtmWvUxY6kN/L5tCJRaN1yrIa7m863kzXMGmduZc1RqAc68IvwM/lB/GM8iJtS XdKzxadRSaQ12OGXUAKpKV5heTl15iAZGzw1Yk9zedZlZwYPfTgKjSJev4s7yKD6JTnn qxNnZRJuOlzppGHHLTnBrw1XF1cl8xJJYlwAq3iRBx8Lz8B9neV01E66BnlYNMMwc7mR OYPA7zVcd8ihl3qclN9wvTestCwULRavurqd4pNXSlFHLl8DZv7FoRmKgy6VaLQq8dei 15Rg== X-Gm-Message-State: AOAM530uuYNpoGhYaFGxg9T3+RwuSz1ASZLfw7qT+0ZijKkIDxh07c+Y xJeqm6OvDI2ClF28O4gp/q5/vQ== X-Received: by 2002:a17:902:547:: with SMTP id 65mr20764059plf.256.1595299055940; Mon, 20 Jul 2020 19:37:35 -0700 (PDT) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:7220:84ff:fe09:41dc]) by smtp.gmail.com with ESMTPSA id z6sm17888266pfn.173.2020.07.20.19.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 19:37:35 -0700 (PDT) From: Nicolas Boichat To: Marcel Holtmann Cc: Nicolas Boichat , Ian Molton , Johan Hedberg , Sebastian Reichel , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] Bluetooth: hci_serdev: Only unregister device if it was registered Date: Tue, 21 Jul 2020 10:37:16 +0800 Message-Id: <20200721103652.2.I8a2fdad30d42399fa5afc15d66b460d1738c3946@changeid> X-Mailer: git-send-email 2.28.0.rc0.105.gf9edc3c819-goog In-Reply-To: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> References: <20200721103652.1.Idbc7eddf1f24f750a8bbcbc8e06743736ae3be31@changeid> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should not call hci_unregister_dev if the device was not successfully registered. Fixes: c34dc3bfa7642fd ("Bluetooth: hci_serdev: Introduce hci_uart_unregister_device()") Signed-off-by: Nicolas Boichat --- drivers/bluetooth/hci_serdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c index 599855e4c57c13d..7b233312e723fb2 100644 --- a/drivers/bluetooth/hci_serdev.c +++ b/drivers/bluetooth/hci_serdev.c @@ -355,7 +355,8 @@ void hci_uart_unregister_device(struct hci_uart *hu) struct hci_dev *hdev = hu->hdev; clear_bit(HCI_UART_PROTO_READY, &hu->flags); - hci_unregister_dev(hdev); + if (test_bit(HCI_UART_REGISTERED, &hu->flags)) + hci_unregister_dev(hdev); hci_free_dev(hdev); cancel_work_sync(&hu->write_work); -- 2.28.0.rc0.105.gf9edc3c819-goog