diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2019-08-05 22:05:36 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2019-08-05 22:07:43 +0200 |
commit | 5e02f94411b06f192fb2a7d9be9abde3549153a8 (patch) | |
tree | 2718cd4082aab891924b5ba2b185cfb2adb278de /system-linux.c | |
parent | 899f168b9d9555865b35cdf2f69b0d3af8839496 (diff) |
system-linux: fix resource leak
Fix cb leak in case invalid type is specified in system_if_clear_entries
Detected by Coverity in CID1431183
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'system-linux.c')
-rw-r--r-- | system-linux.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/system-linux.c b/system-linux.c index c406a3d..acfd40e 100644 --- a/system-linux.c +++ b/system-linux.c @@ -985,7 +985,7 @@ static void system_if_clear_entries(struct device *dev, int type, int af) { struct clear_data clr; - struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT); + struct nl_cb *cb; struct rtmsg rtm = { .rtm_family = af, .rtm_flags = RTM_F_CLONED, @@ -993,9 +993,6 @@ system_if_clear_entries(struct device *dev, int type, int af) int flags = NLM_F_DUMP; int pending = 1; - if (!cb) - return; - clr.af = af; clr.dev = dev; clr.type = type; @@ -1011,6 +1008,10 @@ system_if_clear_entries(struct device *dev, int type, int af) return; } + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!cb) + return; + clr.msg = nlmsg_alloc_simple(type, flags); if (!clr.msg) goto out; |