* [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences
@ 2007-07-29 14:47 Eugene Teo
2007-07-29 16:49 ` Marcel Holtmann
0 siblings, 1 reply; 5+ messages in thread
From: Eugene Teo @ 2007-07-29 14:47 UTC (permalink / raw)
To: linux-kernel; +Cc: marcel
Commit 22ad42033b7d2b3d7928fba9f89d1c7f8a3c9581 did not completely fix all
the possible NULL dereferences. Besides hci_uart_close(), we also need to
make sure that hdev is valid before calling hci_{unregister,free}_dev().
Signed-off-by: Eugene Teo <eugeneteo@kernel.sg>
---
drivers/bluetooth/hci_ldisc.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 6055b9c..4813f7c 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -308,11 +308,10 @@ static void hci_uart_tty_close(struct tty_struct *tty)
if (hu) {
struct hci_dev *hdev = hu->hdev;
- if (hdev)
+ if (hdev) {
hci_uart_close(hdev);
-
- if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
- hu->proto->close(hu);
+ if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags))
+ hu->proto->close(hu);
hci_unregister_dev(hdev);
hci_free_dev(hdev);
}
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences
2007-07-29 14:47 [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences Eugene Teo
@ 2007-07-29 16:49 ` Marcel Holtmann
2007-07-29 22:53 ` Eugene Teo
0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2007-07-29 16:49 UTC (permalink / raw)
To: Eugene Teo; +Cc: linux-kernel
Hi Eugene,
> Commit 22ad42033b7d2b3d7928fba9f89d1c7f8a3c9581 did not completely fix all
> the possible NULL dereferences. Besides hci_uart_close(), we also need to
> make sure that hdev is valid before calling hci_{unregister,free}_dev().
I don't see any issue. Without HCI_UART_PROTO_SET, the hdev will never
be registered. So no need to protect it twice.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences
2007-07-29 16:49 ` Marcel Holtmann
@ 2007-07-29 22:53 ` Eugene Teo
2007-07-30 6:42 ` Marcel Holtmann
0 siblings, 1 reply; 5+ messages in thread
From: Eugene Teo @ 2007-07-29 22:53 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-kernel
Hi Marcel,
Marcel Holtmann wrote:
>> Commit 22ad42033b7d2b3d7928fba9f89d1c7f8a3c9581 did not completely fix all
>> the possible NULL dereferences. Besides hci_uart_close(), we also need to
>> make sure that hdev is valid before calling hci_{unregister,free}_dev().
>
> I don't see any issue. Without HCI_UART_PROTO_SET, the hdev will never
> be registered. So no need to protect it twice.
Correct me if I am wrong. HCI_UART_PROTO_SET bit is only set if hci_uart_tty_ioctl()
is called with HCIUARTSETPROTO. Is it possible for the HCI device to be registered
and then unregistered without setting the HCI_UART_PROTO_SET bit in hdev->flags?
Thanks,
Eugene
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences
2007-07-29 22:53 ` Eugene Teo
@ 2007-07-30 6:42 ` Marcel Holtmann
2007-07-30 6:48 ` Eugene Teo
0 siblings, 1 reply; 5+ messages in thread
From: Marcel Holtmann @ 2007-07-30 6:42 UTC (permalink / raw)
To: Eugene Teo; +Cc: linux-kernel
Hi Eugene,
> >> Commit 22ad42033b7d2b3d7928fba9f89d1c7f8a3c9581 did not completely fix all
> >> the possible NULL dereferences. Besides hci_uart_close(), we also need to
> >> make sure that hdev is valid before calling hci_{unregister,free}_dev().
> >
> > I don't see any issue. Without HCI_UART_PROTO_SET, the hdev will never
> > be registered. So no need to protect it twice.
>
> Correct me if I am wrong. HCI_UART_PROTO_SET bit is only set if hci_uart_tty_ioctl()
> is called with HCIUARTSETPROTO. Is it possible for the HCI device to be registered
> and then unregistered without setting the HCI_UART_PROTO_SET bit in hdev->flags?
look at the code. The hci_uart_tty_ioctl() is the only function that can
register the HCI device. So besides opening the TTY and set the line
discipline, you also have to the set the UART protocol running on top. I
don't see any way you can achieve to register a HCI device without
setting the HCI_UART_PROTO_SET bit in hu->flags.
Regards
Marcel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences
2007-07-30 6:42 ` Marcel Holtmann
@ 2007-07-30 6:48 ` Eugene Teo
0 siblings, 0 replies; 5+ messages in thread
From: Eugene Teo @ 2007-07-30 6:48 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-kernel
Hi Marcel,
Marcel Holtmann wrote:
>>>> Commit 22ad42033b7d2b3d7928fba9f89d1c7f8a3c9581 did not completely fix all
>>>> the possible NULL dereferences. Besides hci_uart_close(), we also need to
>>>> make sure that hdev is valid before calling hci_{unregister,free}_dev().
>>> I don't see any issue. Without HCI_UART_PROTO_SET, the hdev will never
>>> be registered. So no need to protect it twice.
>> Correct me if I am wrong. HCI_UART_PROTO_SET bit is only set if hci_uart_tty_ioctl()
>> is called with HCIUARTSETPROTO. Is it possible for the HCI device to be registered
>> and then unregistered without setting the HCI_UART_PROTO_SET bit in hdev->flags?
>
> look at the code. The hci_uart_tty_ioctl() is the only function that can
> register the HCI device. So besides opening the TTY and set the line
> discipline, you also have to the set the UART protocol running on top. I
> don't see any way you can achieve to register a HCI device without
> setting the HCI_UART_PROTO_SET bit in hu->flags.
Ok. Thanks for the explanation.
Eugene
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-07-30 6:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29 14:47 [PATCH] drivers/bluetooth/hci_ldisc.c: fix possible NULL dereferences Eugene Teo
2007-07-29 16:49 ` Marcel Holtmann
2007-07-29 22:53 ` Eugene Teo
2007-07-30 6:42 ` Marcel Holtmann
2007-07-30 6:48 ` Eugene Teo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox