]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: fix construction of USB specifier-based names
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 9 Dec 2025 13:22:55 +0000 (22:22 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 12 Mar 2026 00:24:48 +0000 (00:24 +0000)
Commit 0bac1ed242 ("tree-wide: Fix constness issues with newer glibc")
split a temporary var in get_usb_specifier to const and non-const
versions, but missed converting a couple of uses. This means we get
names of with components of:

 port: uN
 config: cC.I
 interface: iC.I

instead of:

 port: uN
 config: cC
 interface: iI

This results in net names like enu1c1.0i1.0, as we also no longer hit
the config==1 and interf==0 elision cases.

Change the config portion handling to start from the correct position,
and the earlier check for NULL.

(cherry picked from commit b10b4303c6332e6432debb6664bc30ceddbe70f1)
(cherry picked from commit 8612c4c5e57b87b09fc69b8e0b6a2ea099a4c0f6)

src/udev/udev-builtin-net_id.c

index 26ddc101cbea5d9c8c140d4d87ea6288f83cf10a..c72c87a38ca062fc98b95a7d2bc8b5690404b861 100644 (file)
@@ -976,14 +976,14 @@ static int get_usb_specifier(sd_device *dev, char **ret) {
 
         ports = strdupa_safe(s + 1);
         char *t = strchr(ports, ':');
-        if (!s)
+        if (!t)
                 return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
                                               "sysname \"%s\" does not have ':' in the expected place.", sysname);
 
         *t = '\0';
         config = t + 1;
-        s = strchr(config, '.');
-        if (!s)
+        t = strchr(config, '.');
+        if (!t)
                 return log_device_debug_errno(dev, SYNTHETIC_ERRNO(EINVAL),
                                               "sysname \"%s\" does not have '.' in the expected place.", sysname);