lkml.org 
[lkml]   [2013]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] usb: fix cleanup after failure in hub_configure()
On Tue, 20 Aug 2013, Krzysztof Mazur wrote:

> > Why bother with a separate jump label? Just set maxchild to 0 whenever
> > a failure occurs.
> >
>
> Initially I had just straightforward "dev->maxchild = 0;" after fail,
> but I changed that to simplify the second patch and be able to
> use goto fail:
>
> ret = usb_hub_create_port_device(hub, i + 1);
> if (ret < 0) {
> dev_err(hub->intfdev,
> "couldn't create port%d device.\n", i + 1);
> hdev->maxchild = i;
> goto fail;
> }
>
> and avoid "return ret" here or something like
>
> if (hdev->maxchild == hub->descriptor->bNbrPorts)
> hdev->maxchild = 0;
>
> in the fail path.

The second patch can either clean up the port devices by hand, or else
jump to a new label after the line that sets maxchild to 0.

Alan Stern



\
 
 \ /
  Last update: 2013-08-20 21:21    [W:0.047 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site