* [PATCH] Link usb controller struct only when initialised
@ 2009-06-07 18:37 Oliver Henshaw
2009-06-08 23:57 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Henshaw @ 2009-06-07 18:37 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 591 bytes --]
When controller initialisation is aborted in grub_uhci_pci_iter
(grub_ohci_pci_iter) control
jumps to "fail:", where any allocated memory is freed. However, the
struct grub_uhci *u
(struct grub_ohci *o) for that controller remains linked to the list
of UHCI (OHCI)
controllers. This causes problems later, when grub iterates over
controllers to initialise
their ports.
The solution is to link only when the usb controller is successfully
initialised, and just
before returning from the function.
This patch is tested with real hardware and with qemu and the rescue image.
Thanks,
Oliver
[-- Attachment #2: usb-link-struct-after-init.patch --]
[-- Type: text/x-patch, Size: 1399 bytes --]
ChangeLog:
* bus/usb/ohci.c: Link struct only after initialising controller.
* bus/usb/uhci.c: Likewise.
Index: bus/usb/ohci.c
===================================================================
--- bus/usb/ohci.c (revision 2216)
+++ bus/usb/ohci.c (working copy)
@@ -153,9 +153,6 @@ grub_ohci_pci_iter (int bus, int device, int func,
if (! o)
return 1;
- /* Link in the OHCI. */
- o->next = ohci;
- ohci = o;
o->iobase = (grub_uint32_t *) base;
/* Reserve memory for the HCCA. */
@@ -189,6 +186,10 @@ grub_ohci_pci_iter (int bus, int device, int func,
grub_dprintf ("ohci", "OHCI enable: 0x%02x\n",
(grub_ohci_readreg32 (o, GRUB_OHCI_REG_CONTROL) >> 6) & 3);
+ /* link to ohci now that initialisation is successful. */
+ o->next = ohci;
+ ohci = o;
+
return 0;
fail:
Index: bus/usb/uhci.c
===================================================================
--- bus/usb/uhci.c (revision 2216)
+++ bus/usb/uhci.c (working copy)
@@ -173,8 +173,6 @@ grub_uhci_pci_iter (int bus, int device, int func,
if (! u)
return 1;
- u->next = uhci;
- uhci = u;
u->iobase = base & GRUB_UHCI_IOMASK;
u->framelist = 0;
u->qh = 0;
@@ -287,6 +285,10 @@ grub_uhci_pci_iter (int bus, int device, int func,
}
#endif
+ /* link to uhci now that initialisation is successful. */
+ u->next = uhci;
+ uhci = u;
+
return 0;
fail:
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Link usb controller struct only when initialised
2009-06-07 18:37 [PATCH] Link usb controller struct only when initialised Oliver Henshaw
@ 2009-06-08 23:57 ` Vladimir 'phcoder' Serbinenko
2009-06-09 0:01 ` Pavel Roskin
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-06-08 23:57 UTC (permalink / raw)
To: The development of GRUB 2
Commited with small stylistic change: comments start with an uppercase
letter and end with 2 spaces
On Sun, Jun 7, 2009 at 8:37 PM, Oliver Henshaw<oliver.henshaw@gmail.com> wrote:
> When controller initialisation is aborted in grub_uhci_pci_iter
> (grub_ohci_pci_iter) control
> jumps to "fail:", where any allocated memory is freed. However, the
> struct grub_uhci *u
> (struct grub_ohci *o) for that controller remains linked to the list
> of UHCI (OHCI)
> controllers. This causes problems later, when grub iterates over
> controllers to initialise
> their ports.
>
> The solution is to link only when the usb controller is successfully
> initialised, and just
> before returning from the function.
>
> This patch is tested with real hardware and with qemu and the rescue image.
>
>
> Thanks,
> Oliver
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
>
--
Regards
Vladimir 'phcoder' Serbinenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-06-09 0:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-07 18:37 [PATCH] Link usb controller struct only when initialised Oliver Henshaw
2009-06-08 23:57 ` Vladimir 'phcoder' Serbinenko
2009-06-09 0:01 ` Pavel Roskin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.