Re: [PATCH 3.14 30/59] xhci: refuse loading if nousb is used

From: Greg Kroah-Hartman
Date: Sun Jan 31 2016 - 14:10:21 EST


On Thu, Jan 28, 2016 at 05:57:35PM +0000, Luis Henriques wrote:
> On Wed, Jan 27, 2016 at 10:15:18AM -0800, Greg Kroah-Hartman wrote:
> > 3.14-stable review patch. If anyone has any objections, please let me know.
> >
> > ------------------
> >
> > From: Oliver Neukum <oneukum@xxxxxxxx>
> >
> > commit 1eaf35e4dd592c59041bc1ed3248c46326da1f5f upstream.
> >
> > The module should fail to load.
> >
> > Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> >
> > ---
> > drivers/usb/host/xhci.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > --- a/drivers/usb/host/xhci.c
> > +++ b/drivers/usb/host/xhci.c
> > @@ -4893,6 +4893,10 @@ static int __init xhci_hcd_init(void)
> > BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
> > /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
> > BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
> > +
> > + if (usb_disabled())
> > + return -ENODEV;
> > +
>
> I believe the error path should actually call xhci_unregister_pci().
> Something like the patch below. The same is applies to the 3.10
> kernel.
>
> Cheers,
> --
> Luís
>
> > return 0;
> > unreg_pci:
> > xhci_unregister_pci();
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe stable" in
> > the body of a message to majordomo@xxxxxxxxxxxxxxx
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> >From 870b9e9479b67df493e2ca3c763102b10d4dd9da Mon Sep 17 00:00:00 2001
> From: Oliver Neukum <oneukum@xxxxxxxx>
> Date: Thu, 3 Dec 2015 15:03:34 +0100
> Subject: xhci: refuse loading if nousb is used
>
> commit 1eaf35e4dd592c59041bc1ed3248c46326da1f5f upstream.
>
> The module should fail to load.
>
> Signed-off-by: Oliver Neukum <oneukum@xxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> [ luis: need to call xhci_unregister_pci() in the error path ]
> Signed-off-by: Luis Henriques <luis.henriques@xxxxxxxxxxxxx>
> ---
> drivers/usb/host/xhci.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 20209e870a99..4c78dc564b3a 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4955,6 +4955,12 @@ static int __init xhci_hcd_init(void)
> BUILD_BUG_ON(sizeof(struct xhci_intr_reg) != 8*32/8);
> /* xhci_run_regs has eight fields and embeds 128 xhci_intr_regs */
> BUILD_BUG_ON(sizeof(struct xhci_run_regs) != (8+8*128)*32/8);
> +
> + if (usb_disabled()) {
> + retval = -ENODEV;
> + goto unreg_pci;
> + }

No, we should move the check much higher up to the top of the function,
which makes it simpler. I'll go do that instead, thanks.

greg k-h