|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
From 9dd94c0ac4b29250e0c06f2bbd8e73cc2072da7d Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
From: Dave Reisner <d@falconindy.com>
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Date: Sun, 27 Nov 2016 17:05:39 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Subject: [PATCH] device: Avoid calling unit_free(NULL) in device setup logic
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
(#4748)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Since a581e45ae8f9bb5c, there's a few function calls to
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
unit_new_for_name which will unit_free on failure. Prior to this commit,
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
a failure would result in calling unit_free with a NULL unit, and hit an
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
assertion failure, seen at least via device_setup_unit:
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Assertion 'u' failed at src/core/unit.c:519, function unit_free(). Aborting.
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Fixes #4747
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
https://bugs.archlinux.org/task/51950
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
(cherry picked from commit d112eae7da77899be245ab52aa1747d4675549f1)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
---
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
src/core/device.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
diff --git a/src/core/device.c b/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
index bd87a447cd..4b9e84aeb6 100644
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
--- a/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+++ b/src/core/device.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
@@ -365,7 +365,7 @@ static int device_setup_unit(Manager *m, struct udev_device *dev, const char *pa
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
fail:
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
log_unit_warning_errno(u, r, "Failed to set up device unit: %m");
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
- if (delete)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ if (delete && u)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
unit_free(u);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
return r;
|