]> git.hungrycats.org Git - linux/commitdiff
[PATCH] ohci-hcd, paranoia
authorDavid Brownell <david-b@pacbell.net>
Mon, 30 Sep 2002 09:41:46 +0000 (02:41 -0700)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 30 Sep 2002 09:41:46 +0000 (02:41 -0700)
In a test where some memory corruption happened, I noticed an
oops (null pointer exception in_irq) that's avoidable.  Here's
a patch that avoids it ... anyone seeing the err() is likely
to hang some process, but that's better than the alternative.
(Also inlines some used-once routines, saving a bit of space
to make up for the new diagnostic.)

drivers/usb/host/ohci-mem.c
drivers/usb/host/ohci-q.c

index 51322551606baa15f2a2c1fd4785ea7d542297fc..bde7dfef56e5a084a3d6230f7ff94ce50a73c8e0 100644 (file)
@@ -48,10 +48,10 @@ dma_to_ed_td (struct hash_list_t * entry, dma_addr_t dma)
        struct hash_t * scan = entry->head;
        while (scan && scan->dma != dma)
                scan = scan->next;
-       return scan->virt;
+       return scan ? scan->virt : 0;
 }
 
-static struct td *
+static inline struct td *
 dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma)
 {
        td_dma &= TD_MASK;
@@ -62,7 +62,7 @@ dma_to_td (struct ohci_hcd *hc, dma_addr_t td_dma)
 // FIXME:  when updating the hashtables this way, mem_flags is unusable...
 
 /* Add a hash entry for a TD/ED; return true on success */
-static int
+static inline int
 hash_add_ed_td (
        struct hash_list_t *entry,
        void *virt,
@@ -97,7 +97,7 @@ hash_add_td (struct ohci_hcd *hc, struct td *td, int mem_flags)
 }
 
 
-static void
+static inline void
 hash_free_ed_td (struct hash_list_t *entry, void *virt)
 {
        struct hash_t *scan, *prev;
index 2b5e3e17e266b31383d78e4ba4b4e2cd0f6552cd..8385033e389109e1b8ddfbbf76f23c5967cc9f6b 100644 (file)
@@ -854,6 +854,11 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
                int             cc;
 
                td = dma_to_td (ohci, td_dma);
+               if (!td) {
+                       err ("%s bad entry %8x",
+                               ohci->hcd.self.bus_name, td_dma);
+                       break;
+               }
 
                td->hwINFO |= cpu_to_le32 (TD_DONE);
                cc = TD_CC_GET (le32_to_cpup (&td->hwINFO));