]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: fix parent token handling
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 6 May 2022 17:29:39 +0000 (02:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 6 May 2022 17:51:21 +0000 (02:51 +0900)
This fixes a bug introduced by 03677889f0ef42cdc534bf3b31265a054b20a354.

Fixes #23288.

src/udev/udev-rules.c

index 1c20775f0826cc68bb9c7cfb2470e9d6e9ae2427..fa225476b64ce68ec2a0093f358b89902a195ed8 100644 (file)
@@ -2425,11 +2425,15 @@ static int udev_rule_apply_parent_token_to_event(
         UdevRuleToken *head;
         int r;
 
-        line = rules->current_file->current_line;
-        head = rules->current_file->current_line->current_token;
-        event->dev_parent = event->dev;
+        assert(rules);
+        assert(rules->current_file);
+        assert(event);
+
+        line = ASSERT_PTR(rules->current_file->current_line);
+        head = ASSERT_PTR(rules->current_file->current_line->current_token);
+        event->dev_parent = ASSERT_PTR(event->dev);
+
         for (;;) {
-                line->current_token = NULL;
                 LIST_FOREACH(tokens, token, head) {
                         if (!token_is_for_parents(token))
                                 return true; /* All parent tokens match. */
@@ -2441,8 +2445,8 @@ static int udev_rule_apply_parent_token_to_event(
                         if (r == 0)
                                 break;
                 }
-                if (!line->current_token)
-                        /* All parent tokens match. But no assign tokens in the line. Hmm... */
+                if (r > 0)
+                        /* All parent tokens match, and no more token (except for GOTO) in the line. */
                         return true;
 
                 if (sd_device_get_parent(event->dev_parent, &event->dev_parent) < 0) {