]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
device: Avoid calling unit_free(NULL) in device setup logic (#4748)
authorDave Reisner <d@falconindy.com>
Sun, 27 Nov 2016 22:05:39 +0000 (17:05 -0500)
committerMartin Pitt <martin.pitt@ubuntu.com>
Sun, 27 Nov 2016 22:05:39 +0000 (23:05 +0100)
Since a581e45ae8f9bb5c, there's a few function calls to
unit_new_for_name which will unit_free on failure. Prior to this commit,
a failure would result in calling unit_free with a NULL unit, and hit an
assertion failure, seen at least via device_setup_unit:

Assertion 'u' failed at src/core/unit.c:519, function unit_free().  Aborting.

Fixes #4747
https://bugs.archlinux.org/task/51950

src/core/device.c

index 074e93ffe2ea0ea7ab4c9bdfb53831430d21cd6b..8e2e3c7bedc299235d077855f4a2f50f761335b4 100644 (file)
@@ -359,7 +359,7 @@ static int device_setup_unit(Manager *m, struct udev_device *dev, const char *pa
 fail:
         log_unit_warning_errno(u, r, "Failed to set up device unit: %m");
 
-        if (delete)
+        if (delete && u)
                 unit_free(u);
 
         return r;