chiark / gitweb /
unit: fix assert when trying to load unit instances for uninstanciable types
[elogind.git] / src / unit.c
index aed25e4f215e34f437a8cf55db4b9270fc9e28a4..b7ff0c51fe9f40b4914da36d8513232ce40e9500 100644 (file)
@@ -118,8 +118,10 @@ int unit_add_name(Unit *u, const char *text) {
         if ((r = unit_name_to_instance(s, &i)) < 0)
                 goto fail;
 
-        if (i && unit_vtable[t]->no_instances)
+        if (i && unit_vtable[t]->no_instances) {
+                r = -EINVAL;
                 goto fail;
+        }
 
         /* Ensure that this unit is either instanced or not instanced,
          * but not both. */