Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672Ab3HTS7U (ORCPT ); Tue, 20 Aug 2013 14:59:20 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:46665 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751351Ab3HTS7T (ORCPT ); Tue, 20 Aug 2013 14:59:19 -0400 Date: Tue, 20 Aug 2013 14:59:18 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Krzysztof Mazur cc: linux-usb@vger.kernel.org, Greg Kroah-Hartman , , Daniel J Blueman Subject: Re: [PATCH 1/2] usb: fix cleanup after failure in hub_configure() In-Reply-To: <20130820184236.GA782@shrek.podlesie.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1040 Lines: 35 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/