diff options
author | Andrea Righi <arighi@develer.com> | 2010-06-28 10:56:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-08-10 17:35:38 -0400 |
commit | 4307a28eb0128417d9a2b9d858d2bce70ee5b383 (patch) | |
tree | 46efab423c646ba4a994533b1e5befe523fbf08a | |
parent | e10fa4787f1fb9c8738dff955c272f30b7b63134 (diff) |
USB: EHCI: fix NULL pointer dererence in HCDs that use HCD_LOCAL_MEM
If we use the HCD_LOCAL_MEM flag and dma_declare_coherent_memory() to
enforce the host controller's local memory utilization we also need to
disable native scatter-gather support, otherwise hcd_alloc_coherent() in
map_urb_for_dma() is called with urb->transfer_buffer == NULL, that
triggers a NULL pointer dereference.
We can also consider to add a WARN_ON() and return an error code to
better catch this problem in the future.
At the moment no driver seems to hit this bug, so I should
consider this a low-priority fix.
Signed-off-by: Andrea Righi <arighi@develer.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/hcd.c | 5 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 3 |
2 files changed, 7 insertions, 1 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 0358c05e6e8a..c5753c797735 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -1218,6 +1218,11 @@ static int hcd_alloc_coherent(struct usb_bus *bus, | |||
1218 | { | 1218 | { |
1219 | unsigned char *vaddr; | 1219 | unsigned char *vaddr; |
1220 | 1220 | ||
1221 | if (*vaddr_handle == NULL) { | ||
1222 | WARN_ON_ONCE(1); | ||
1223 | return -EFAULT; | ||
1224 | } | ||
1225 | |||
1221 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), | 1226 | vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr), |
1222 | mem_flags, dma_handle); | 1227 | mem_flags, dma_handle); |
1223 | if (!vaddr) | 1228 | if (!vaddr) |
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 2a19336c9824..2e704fa3cedf 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -629,7 +629,8 @@ static int ehci_init(struct usb_hcd *hcd) | |||
629 | ehci->command = temp; | 629 | ehci->command = temp; |
630 | 630 | ||
631 | /* Accept arbitrarily long scatter-gather lists */ | 631 | /* Accept arbitrarily long scatter-gather lists */ |
632 | hcd->self.sg_tablesize = ~0; | 632 | if (!(hcd->driver->flags & HCD_LOCAL_MEM)) |
633 | hcd->self.sg_tablesize = ~0; | ||
633 | return 0; | 634 | return 0; |
634 | } | 635 | } |
635 | 636 | ||