[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1302261100210.1832-100000@iolanthe.rowland.org>
Date: Tue, 26 Feb 2013 11:07:30 -0500 (EST)
From: Alan Stern <stern@...land.harvard.edu>
To: Daniel J Blueman <daniel@...ascale-asia.com>
cc: linux-usb@...r.kernel.org, <linux-kernel@...r.kernel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sarah Sharp <sarah.a.sharp@...ux.intel.com>,
Steffen Persvold <sp@...ascale.com>
Subject: Re: [PATCH] Prevent USB hub remove oops
On Tue, 26 Feb 2013, Daniel J Blueman wrote:
> When initialisation of one or more USB hub ports fails, we can hit a null
> pointer dereference when dropping the hub. Analysis shows there's a false
> assumption about the ports being setup, so address this.
> Signed-off-by: Daniel J Blueman <daniel@...ascale-asia.com>
> ---
> drivers/usb/core/hub.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index cbf7168..a7abc57 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -1263,7 +1263,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
> if (type != HUB_SUSPEND) {
> /* Disconnect all the children */
> for (i = 0; i < hdev->maxchild; ++i) {
> - if (hub->ports[i]->child)
> + if (hub->ports[i] && hub->ports[i]->child)
> usb_disconnect(&hub->ports[i]->child);
> }
> }
You missed a case. What happens if hub->ports is NULL?
Also, what about this code in hub_disconnect?
for (i = 0; i < hdev->maxchild; i++)
usb_hub_remove_port_device(hub, i + 1);
All of these problems can be fixed in hub_configure by setting
hub->maxchild to the total number of allocated ports (or 0 if hub_ports
can't be allocated).
Alan Stern
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists