From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Oliver Neukum <oneukum@suse.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable <stable@kernel.org>
Subject: Re: [PATCH v2] usb: misc: uss720: properly clean up reference in uss720_probe()
Date: Mon, 23 Feb 2026 13:14:35 +0100 [thread overview]
Message-ID: <2026022316-strobe-zombie-335f@gregkh> (raw)
In-Reply-To: <04778e0c-e15c-4acd-ade2-5cb8dc4319b1@suse.com>
On Mon, Feb 23, 2026 at 12:28:29PM +0100, Oliver Neukum wrote:
> Hi,
>
> On 23.02.26 12:17, Greg Kroah-Hartman wrote:
> > If get_1284_register() fails, the usb device reference count is
> > incorrect and needs to be properly dropped before returning.
> >
> > Cc: stable <stable@kernel.org>
> > Assisted-by: gkh_clanker_2000
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > v2: properly clean up the previously allocated resources by jumping to
> > the error path and not just retrning directly
> >
> > drivers/usb/misc/uss720.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
> > index ec8bd968c4de..54107bf280df 100644
> > --- a/drivers/usb/misc/uss720.c
> > +++ b/drivers/usb/misc/uss720.c
> > @@ -735,8 +735,10 @@ static int uss720_probe(struct usb_interface *intf,
> > * here. */
> > ret = get_1284_register(pp, 0, ®, GFP_KERNEL);
> > dev_dbg(&intf->dev, "reg: %7ph\n", priv->reg);
> > - if (ret < 0)
> > - return ret;
> > + if (ret < 0) {
> > + usb_put_dev(usbdev);
> > + goto probe_abort;
>
> This jumps to probe_abort, which calls destroy_priv() indirectly
> via kref_put(). Either that works, which would mean that you must
> _not_ do a second usb_put_dev() or it does not, in which case the
> earlier error handling for parport_register_port() is incorrect.
>
> Either way, there is a problem.
Argh, I missed that part of the error path, you are right. The existing
code is wrong for the earlier cleanup logic, I'll go fix that instead,
thanks for the review.
It's tricky stuff like this which makes me can't wait for rust to be
possible for USB drivers, someday...
thanks,
greg k-h
next prev parent reply other threads:[~2026-02-23 12:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 11:17 [PATCH v2] usb: misc: uss720: properly clean up reference in uss720_probe() Greg Kroah-Hartman
2026-02-23 11:28 ` Oliver Neukum
2026-02-23 12:14 ` Greg Kroah-Hartman [this message]
2026-02-23 12:55 ` Oliver Neukum
2026-02-23 13:09 ` Greg Kroah-Hartman
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=2026022316-strobe-zombie-335f@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox