mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	Jiasheng Jiang <jiashengjiangcool@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chen Yufeng <chenyufeng@iie.ac.cn>,
	Nicholas Bellinger <nab@linux-iscsi.org>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: f_tcm: Fix NULL pointer dereferences in nexus handling
Date: Thu, 19 Feb 2026 01:30:16 +0000	[thread overview]
Message-ID: <20260219012929.u6btnnmqvbyujz5f@synopsys.com> (raw)
In-Reply-To: <20260218072922.C08qI5s1@linutronix.de>

On Wed, Feb 18, 2026, Sebastian Andrzej Siewior wrote:
> On 2026-02-18 05:22:21 [+0000], Thinh Nguyen wrote:
> > > Fixes: 08a1cb0f65fd ("usb: gadget: tcm: factor out f_tcm")
> > > Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
> …
> > While the patch itself is fine, we should prevent this situation from
> > occurring in the first place. That is, we should enforce the config
> > dependency and prevent the users from removing the nexus if the gadget
> > driver is bound. Likewise, we should prevent the gadget driver from
> > binding if no nexus is established.
> 
> Is this an actual problem or just something that looks like it could
> happen? My memory is that the tcm holds a reference on it and the
> referenced commit just split/moved  the code. So if it is a problem then
> it should have been there longer than that.
> 

Looks like we only hold the reference to the session cmds, and we track
the tpg_port_count if there's an established link. But we don't guard or
deactivate the f_tcm usb function when we unregister the tcm and remove
the nexus. As far as the host can tell, the device is still connected
and the function is still active.

This exists since the beginning. The Fixes tag should have pointed to
c52661d60f63 ("usb-gadget: Initial merge of target module for UASP + BOT")

We can guard against unlinking the port while the gadget_driver is bound
or we can just deactivate the usb function when that happens. The latter
is probably a better option.

BR,
Thinh

  reply	other threads:[~2026-02-19  1:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-16 20:48 Jiasheng Jiang
2026-02-18  5:22 ` Thinh Nguyen
2026-02-18  7:29   ` Sebastian Andrzej Siewior
2026-02-19  1:30     ` Thinh Nguyen [this message]
2026-02-19  1:44       ` Jiasheng Jiang
2026-02-19  2:17         ` Thinh Nguyen
2026-02-19  2:38           ` [PATCH v3] " Jiasheng Jiang
2026-02-19 22:57             ` Thinh Nguyen
2026-02-19  1:48       ` [PATCH] " Jiasheng Jiang
2026-02-19  2:13         ` Thinh Nguyen
2026-02-19  2:18           ` [PATCH v2] " Jiasheng Jiang

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=20260219012929.u6btnnmqvbyujz5f@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=andrzej.p@samsung.com \
    --cc=bigeasy@linutronix.de \
    --cc=chenyufeng@iie.ac.cn \
    --cc=gregkh@linuxfoundation.org \
    --cc=jiashengjiangcool@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nab@linux-iscsi.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

all inboxes | Powered by JetHome®