]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd-wwan: handle link_get_by_name() errors in modem_simple_connect()
authornoxiouz <atiurin@proton.me>
Tue, 7 Apr 2026 13:47:11 +0000 (14:47 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 8 Apr 2026 11:59:32 +0000 (13:59 +0200)
modem_simple_connect() ignored the return value of link_get_by_name()
and then checked link for NULL. Since the helper only sets the output
pointer on success, that could read an indeterminate value.

Check and log the return code directly with log_debug_errno().

Co-developed-by: Codex (GPT-5) <noreply@openai.com>
src/network/networkd-wwan-bus.c

index 5d9818987522e4016471fc37cb7bf295d1b34a07..434063ee6c1d5482b2b7c983c00534688a889a1d 100644 (file)
@@ -604,9 +604,9 @@ static void modem_simple_connect(Modem *modem) {
         if (!modem->port_name)
                 return;
 
-        (void) link_get_by_name(modem->manager, modem->port_name, &link);
-        if (!link)
-                return (void) log_debug("ModemManager: cannot find link for %s", modem->port_name);
+        r = link_get_by_name(modem->manager, modem->port_name, &link);
+        if (r < 0)
+                return (void) log_debug_errno(r, "ModemManager: cannot find link for %s: %m", modem->port_name);
 
         /* Check if .network file found at all */
         if (!link->network)