Re: [PATCH] usb: core: Strengthen error handling in hub_hub_status()
From: Alan Stern
Date: Fri Jul 17 2026 - 11:48:26 EST
On Fri, Jul 17, 2026 at 11:48:46AM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jul 14, 2026 at 12:32:06PM -0400, Alan Stern wrote:
> > On Tue, Jul 14, 2026 at 11:04:33AM +0200, Griffin Kroah-Hartman wrote:
> > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > > index 5262e11c12cd..0d2166b8923a 100644
> > > --- a/drivers/usb/core/hub.c
> > > +++ b/drivers/usb/core/hub.c
> > > @@ -991,10 +991,12 @@ static int hub_hub_status(struct usb_hub *hub,
> > >
> > > mutex_lock(&hub->status_mutex);
> > > ret = get_hub_status(hub->hdev, &hub->status->hub);
> > > - if (ret < 0) {
> > > + if (ret < sizeof(hub->status->hub)) {
> > > if (ret != -ENODEV)
> > > dev_err(hub->intfdev,
> > > "%s failed (err = %d)\n", __func__, ret);
> > > + if (ret >= 0)
> > > + ret = -EIO;
> >
> > It would be better to put these two lines above the preceding test.
> > That way it won't print confusing things like "hub_hub_status failed
> > (err = 2)".
>
> It is confusing, but it matches the other check for this same error in
> hub_ext_port_status() as it's the same error condition. How about this
> patch happens first int he series, which "unifies" them, and then fix up
> both of the patterns at the same time to be more clear in a later patch
> in the series?
That would be fine with me.
Alan Stern