summaryrefslogtreecommitdiff
path: root/src/network/networkd-netdev.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-07-01 19:41:45 +0200
committerTom Gundersen <teg@jklm.no>2014-07-01 20:33:30 +0200
commit8900367cd26c148200b4788cd9ae05995ceeb74c (patch)
tree280f5263dd0b96235258fb2560a833e59d098dae /src/network/networkd-netdev.c
parenteafbd4d7cebe50b55324514cc7e95f003dd8ab47 (diff)
networkd: netdev - take ref when creating netdevs
We were doing this correctly for when the callback takes the Link object, but must also do it for the cases it takes the NetDev object.
Diffstat (limited to 'src/network/networkd-netdev.c')
-rw-r--r--src/network/networkd-netdev.c8
1 files changed, 5 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;