All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Jiawen Liu <1298662399@qq.com>
Cc: Juergen Stuber <starblue@users.sourceforge.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	legousb-devel@lists.sourceforge.net, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: legousbtower: clear interface data on probe failure and disconnect
Date: Tue, 18 Aug 2026 16:48:19 +0200	[thread overview]
Message-ID: <aoRws4FhriSazEXG@hovoldconsulting.com> (raw)
In-Reply-To: <tencent_30752557FD78912E64BC2E901338A0D0EF06@qq.com>

On Tue, Aug 18, 2026 at 04:41:28PM +0400, Jiawen Liu wrote:
> From: jiawen <1298662399@qq.com>

Your full name is needed here and below.

> In tower_probe(), usb_set_intfdata() is called before
> usb_register_dev(). If registration fails, the error path calls
> tower_delete() which frees the device, but the interface data still
> points to the freed memory. A subsequent disconnect would dereference
> stale data.

This makes no sense as disconnect() is not called if probe() fails.

> Clear the interface data before freeing the device on the registration
> failure path. Similarly, tower_disconnect() retrieves the interface data
> but never clears it before possibly calling tower_delete(). Clear the
> interface data before the possible tower_delete() call to avoid leaving
> stale interface data after disconnect.

That's not needed either as disconnect() will not free the driver data
until after deregistering the class device (which takes care of any
racing call to open() which accesses the driver data).

> Signed-off-by: jiawen <1298662399@qq.com>

Johan

      reply	other threads:[~2026-08-18 14:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 12:41 [PATCH] usb: legousbtower: clear interface data on probe failure and disconnect Jiawen Liu
2026-08-18 14:48 ` Johan Hovold [this message]

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=aoRws4FhriSazEXG@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=1298662399@qq.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=legousb-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=starblue@users.sourceforge.net \
    /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.