[PATCH] net/9p/usbg: require an exact match for device tags
Jackie Liu <[email protected]> Sun, 19 Jul 2026 12:03:46 +0800
| Newsgroups | dev.linux.lists.v9fs |
|---|---|
| Message-ID | <[email protected]> |
From: Jackie Liu <[email protected]> p9_usbg_create() compares only strlen(devname) bytes while looking up the configfs instance named by the mount source. A source that is a prefix of an instance name therefore selects that instance. For example, source "foo" binds the "foobar" channel instead of failing with -ENOENT. The configfs layer passes the instance name to usb9pfs_set_inst_tag(), and the transport already uses full string comparisons to keep these names unique. Use an exact match for mount lookup too. Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport") Cc: [email protected] Signed-off-by: Jackie Liu <[email protected]> --- net/9p/trans_usbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c index 419cda13a7b5..884d6f4af50c 100644 --- a/net/9p/trans_usbg.c +++ b/net/9p/trans_usbg.c @@ -391,7 +391,7 @@ static int p9_usbg_create(struct p9_client *client, struct fs_context *fc) guard(mutex)(&usb9pfs_lock); list_for_each_entry(dev, &usbg_instance_list, usb9pfs_instance) { - if (!strncmp(devname, dev->tag, strlen(devname))) { + if (!strcmp(devname, dev->tag)) { if (!dev->inuse) { dev->inuse = true; found = 1; -- 2.54.0