From a4cff10ceb3dc98c2924a63c1cb5e5b3dde5dee7 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 20 Feb 2019 14:53:27 +0100 Subject: [PATCH] platform: fix error handling for creating nlmsg in do_request_all_no_delayed_actions() In practice, we don't fail to create the nlmsg, because in glib malloc() cannot fail and we always create large enough buffers. Anyway, handle the error correctly, and reduce the in-progress counter again. --- src/platform/nm-linux-platform.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 09f75a80cf..77a83791fa 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -5248,13 +5248,23 @@ do_request_all_no_delayed_actions (NMPlatform *platform, DelayedActionType actio }; nle = nlmsg_append (nlmsg, &gmsg, sizeof (gmsg), NLMSG_ALIGNTO); } - if (nle < 0) - continue; - if (_nl_send_nlmsg (platform, nlmsg, NULL, NULL, DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, out_refresh_all_in_progress) < 0) { - nm_assert (*out_refresh_all_in_progress > 0); - *out_refresh_all_in_progress -= 1; - } + if (nle < 0) + goto next_after_fail; + + if (_nl_send_nlmsg (platform, + nlmsg, + NULL, + NULL, + DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, + out_refresh_all_in_progress) < 0) + goto next_after_fail; + + continue; + +next_after_fail: + nm_assert (*out_refresh_all_in_progress > 0); + *out_refresh_all_in_progress -= 1; } }