From: Marcel Holtmann <marcel@holtmann.org>
To: "J.D." <jd@freeshell.org>
Cc: BlueZ Mailing List <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] Re: Linux 2.4.27rc3 and Bluetooth
Date: Sat, 24 Jul 2004 22:35:15 +0200 [thread overview]
Message-ID: <1090701315.4791.75.camel@pegasus> (raw)
In-Reply-To: <Pine.NEB.4.60.0407240115590.25504@norge.freeshell.org>
[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]
Hi John,
> I finally burned some time, studied the code, and created a
> working patch for bt3c_cs.c (patch attached). It adds a test
> in bt3c_release to check whether the DEV_CONFIG_PENDING bit of
> link->state is clear before a call to bt3c_close. If the
> DEV_CONFIG_PENDING bit is not clear, bt3c_open has failed,
> and never succeeded in a call to hci_register_dev and friends.
>
> When loading the firmware fails, the unpatched code ignores the
> failure of bt3c_open, goes ahead with bt3c_close, and invokes
> hci_unregister_dev and friends (despite the fact that
> hci_register_dev was never called), thus provoking a kernel panic
> with the NULL pointer dereference. (aiee!)
you are right. That is the problem. I fixed it in a different way.
Please try out the attached patch and report if it also works.
> I suspect the 2.6 kernel may have the same problem by casual
> inspection, but I have neither confirmed the existence of a problem
> through testing of the 2.6 kernel, nor carefully traced that code
> of Linux 2.6 for possible key differences.
No. The 2.6 kernel is not affected, because the hdev is a pointer in
that kernel series and we have the NULL pointer check in place.
Regards
Marcel
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1688 bytes --]
===== drivers/bluetooth/dtl1_cs.c 1.2 vs edited =====
--- 1.2/drivers/bluetooth/dtl1_cs.c 2002-08-03 13:53:56 +02:00
+++ edited/drivers/bluetooth/dtl1_cs.c 2004-07-24 22:30:33 +02:00
@@ -535,6 +535,9 @@
unsigned int iobase = info->link.io.BasePort1;
struct hci_dev *hdev = &(info->hdev);
+ if (info->link.state & DEV_CONFIG_PENDING)
+ return -ENODEV;
+
dtl1_hci_close(hdev);
spin_lock_irqsave(&(info->lock), flags);
===== drivers/bluetooth/bluecard_cs.c 1.1 vs edited =====
--- 1.1/drivers/bluetooth/bluecard_cs.c 2002-08-03 13:54:07 +02:00
+++ edited/drivers/bluetooth/bluecard_cs.c 2004-07-24 22:30:53 +02:00
@@ -803,6 +803,9 @@
unsigned int iobase = info->link.io.BasePort1;
struct hci_dev *hdev = &(info->hdev);
+ if (info->link.state & DEV_CONFIG_PENDING)
+ return -ENODEV;
+
bluecard_hci_close(hdev);
clear_bit(CARD_READY, &(info->hw_state));
===== drivers/bluetooth/bt3c_cs.c 1.2 vs edited =====
--- 1.2/drivers/bluetooth/bt3c_cs.c 2004-04-16 14:05:25 +02:00
+++ edited/drivers/bluetooth/bt3c_cs.c 2004-07-24 22:31:11 +02:00
@@ -643,6 +643,9 @@
{
struct hci_dev *hdev = &(info->hdev);
+ if (info->link.state & DEV_CONFIG_PENDING)
+ return -ENODEV;
+
bt3c_hci_close(hdev);
if (hci_unregister_dev(hdev) < 0)
===== drivers/bluetooth/btuart_cs.c 1.1 vs edited =====
--- 1.1/drivers/bluetooth/btuart_cs.c 2002-10-20 21:42:54 +02:00
+++ edited/drivers/bluetooth/btuart_cs.c 2004-07-24 22:30:46 +02:00
@@ -556,6 +556,9 @@
unsigned int iobase = info->link.io.BasePort1;
struct hci_dev *hdev = &(info->hdev);
+ if (info->link.state & DEV_CONFIG_PENDING)
+ return -ENODEV;
+
btuart_hci_close(hdev);
spin_lock_irqsave(&(info->lock), flags);
next prev parent reply other threads:[~2004-07-24 20:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Pine.NEB.4.60.0407131537590.12135@norge.freeshell.org>
[not found] ` <1089826204.4517.0.camel@pegasus>
[not found] ` <Pine.NEB.4.60.0407141844100.22049@mx.freeshell.org>
[not found] ` <1090055676.4558.15.camel@pegasus>
2004-07-24 7:36 ` Linux 2.4.27rc3 and Bluetooth J.D.
2004-07-24 20:35 ` Marcel Holtmann [this message]
2004-07-30 13:36 ` John Dahlstrom
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1090701315.4791.75.camel@pegasus \
--to=marcel@holtmann.org \
--cc=bluez-devel@lists.sourceforge.net \
--cc=jd@freeshell.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox