summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/networkd-netdev.c8
-rw-r--r--src/network/networkd-veth.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index a53f046540..20917e334b 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -224,7 +224,7 @@ static int netdev_enter_ready(NetDev *netdev) {
/* callback for netdev's created without a backing Link */
static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
- NetDev *netdev = userdata;
+ _cleanup_netdev_unref_ NetDev *netdev = userdata;
int r;
assert(netdev->state != _NETDEV_STATE_INVALID);
@@ -388,9 +388,11 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
if (link)
r = sd_rtnl_call_async(netdev->manager->rtnl, req, callback, link, 0, NULL);
- else
+ else {
r = sd_rtnl_call_async(netdev->manager->rtnl, req, &netdev_create_handler, netdev, 0, NULL);
- if (r < 0) {
+
+ netdev_ref(netdev);
+ } if (r < 0) {
log_error_netdev(netdev,
"Could not send rtnetlink message: %s", strerror(-r));
return r;
diff --git a/src/network/networkd-veth.c b/src/network/networkd-veth.c
index 3584981cbc..3eac90ba90 100644
--- a/src/network/networkd-veth.c
+++ b/src/network/networkd-veth.c
@@ -145,6 +145,8 @@ int netdev_create_veth(NetDev *netdev, sd_rtnl_message_handler_t callback) {
return r;
}
+ netdev_ref(netdev);
+
log_debug_netdev(netdev, "Creating veth netdev: %s",
netdev_kind_to_string(netdev->kind));