On Fri, 12 Mar 2010 15:55:28 +0100, Peter Korsgaard <jacmet@xxxxxxxxxx> wrote:
Contrary to the comment in fsg_add, fsg_bind calls fsg_unbind on errors, which decreases refcount and frees the fsg_dev structure, causing trouble when fsg_add does the same. Fix it by simply leaving up cleanup to fsg_add().
This is of course correct. Thanks for spotting that. What's more struct fsg_dev cannot be freed inside fsg_bind() because usb_function_add() uses struct usb_function (which is part of the former) even after fsg_bind() fails.
Signed-off-by: Peter Korsgaard <jacmet@xxxxxxxxxx>
Acked-by: Michal Nazarewicz <m.nazarewicz@xxxxxxxxxxx>
--- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2954,7 +2954,6 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) autoconf_fail: ERROR(fsg, "unable to autoconfigure all endpoints\n"); rc = -ENOTSUPP; - fsg_unbind(c, f); return rc; }
-- Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał "mina86" Nazarewicz (o o) ooo +---[mina86@xxxxxxxxxx]---[mina86@jabber.org]---ooO--(_)--Ooo-- -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html