From: Sergei Shtylyov <sshtylyov@mvista.com>
To: Felipe Balbi <felipe.balbi@nokia.com>
Cc: Greg KH <greg@kroah.com>,
Linux USB Mailing List <linux-usb@vger.kernel.org>,
Linux OMAP Mailing List <linux-omap@vger.kernel.org>
Subject: Re: [patch-2.6.34-rc2+ 11/11] musb_core: fix musb_init_controller() error cleanup path
Date: Wed, 24 Mar 2010 15:16:09 +0300 [thread overview]
Message-ID: <4BAA0289.1090807@ru.mvista.com> (raw)
In-Reply-To: <1269431279-22438-12-git-send-email-felipe.balbi@nokia.com>
Hello.
Felipe Balbi wrote:
> From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
>
> This function forgets to call usb_remove_hcd() or musb_gadget_cleanup() iff
> sysfs_create_group() fails.
>
> Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
>
> [ felipe.balbi@nokia.com : review the entire error path
> not only when we fail hcd or gadget ]
>
> Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
> ---
> drivers/usb/musb/musb_core.c | 50 +++++++++++++++++++++++++++--------------
> 1 files changed, 33 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 90ac17b..13f36bf 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
[...]
> @@ -2047,7 +2052,7 @@ bad_config:
>
> }
> if (status < 0)
> - goto fail2;
> + goto fail4;
>
No, the label should be 'fail3' here. In this case usb_add_hcd() or
musb_gadget_setup() have failed, so we shouldn't undo them...
> status = musb_init_debugfs(musb);
> if (status < 0)
>
Is there also a 'goto' that needs to be fixed up?
> @@ -2056,7 +2061,7 @@ bad_config:
> #ifdef CONFIG_SYSFS
> status = sysfs_create_group(&musb->controller->kobj, &musb_attr_group);
> if (status)
> - goto fail2;
> + goto fail4;
> #endif
>
> dev_info(dev, "USB %s mode controller at %p using %s, IRQ %d\n",
> @@ -2073,17 +2078,28 @@ bad_config:
>
> return 0;
>
> -fail2:
> +fail4:
> + if (!is_otg_enabled(musb) && is_host_enabled(musb))
> + usb_remove_hcd(musb_to_hcd(musb));
> + else
> + musb_gadget_cleanup(musb);
> + device_init_wakeup(dev, 0);
> +
> +fail3:
> musb_platform_exit(musb);
> -fail:
> - dev_err(musb->controller,
> - "musb_init_controller failed with status %d\n", status);
>
> +fail2:
> if (musb->clock)
> clk_put(musb->clock);
> - device_init_wakeup(dev, 0);
> +
> +fail1:
> + dev_err(musb->controller,
> + "musb_init_controller failed with status %d\n", status);
> +
> musb_free(musb);
>
> +fail0:
> +
> return status;
>
> }
>
WBR, Sergei
next prev parent reply other threads:[~2010-03-24 12:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 11:47 [patch-2.6.34-rc2+ 00/11] musb patches Felipe Balbi
[not found] ` <1269431279-22438-1-git-send-email-felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 01/11] musb: fix power field to hold all possible values Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 02/11] MUSB: fix DaVinci glue layer dependency Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 03/11] MUSB: Blackfin: don't fake blackfin_interrupt() result Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 08/11] MUSB: DaVinci: fix musb_platform_init() error cleanup path Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 09/11] MUSB: OMAP: don't call clk_put() Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 04/11] musb: save and restore missing bus control register Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 05/11] musb: potential use after free Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 06/11] musb_core: don't touch 'musb->clock' in musb_free() Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 07/11] musb_core: don't prevent disabling clock on driver unload Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 10/11] musb_core: don't call musb_platform_exit() twice Felipe Balbi
[not found] ` <1269431279-22438-11-git-send-email-felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-03-24 12:10 ` Sergei Shtylyov
2010-03-24 12:26 ` Sergei Shtylyov
[not found] ` <4BAA0122.2060402-hkdhdckH98+B+jHODAdFcQ@public.gmane.org>
2010-03-25 6:37 ` Felipe Balbi
2010-03-24 11:47 ` [patch-2.6.34-rc2+ 11/11] musb_core: fix musb_init_controller() error cleanup path Felipe Balbi
2010-03-24 12:16 ` Sergei Shtylyov [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-03-25 11:14 [patch-2.6.34-rc2+ 00/11] musb patches (v2) Felipe Balbi
[not found] ` <1269515673-27980-1-git-send-email-felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
2010-03-25 11:14 ` [patch-2.6.34-rc2+ 11/11] musb_core: fix musb_init_controller() error cleanup path Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4BAA0289.1090807@ru.mvista.com \
--to=sshtylyov@mvista.com \
--cc=felipe.balbi@nokia.com \
--cc=greg@kroah.com \
--cc=linux-omap@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.