|
|
2aacef |
From 44d34632660f8456b7ca09510ed1b469541fac65 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
2aacef |
Date: Mon, 16 Jan 2023 22:07:06 +0900
|
|
|
2aacef |
Subject: [PATCH] network: fix memleak
|
|
|
2aacef |
|
|
|
2aacef |
Fixes a bug introduced by af2aea8bb64b0dc42ecbe5549216eb567681a803.
|
|
|
2aacef |
|
|
|
2aacef |
Fixes #25883 and #25891.
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 303dfa73b389e8f6dc58954e867c21724c1446f7)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2138081
|
|
|
2aacef |
---
|
|
|
2aacef |
src/network/networkd-address.c | 6 +++++-
|
|
|
2aacef |
src/network/networkd-route.c | 6 +++++-
|
|
|
2aacef |
2 files changed, 10 insertions(+), 2 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
|
|
|
2aacef |
index 259cd312c9..4f8f95cba6 100644
|
|
|
2aacef |
--- a/src/network/networkd-address.c
|
|
|
2aacef |
+++ b/src/network/networkd-address.c
|
|
|
2aacef |
@@ -1189,9 +1189,13 @@ int link_request_address(
|
|
|
2aacef |
|
|
|
2aacef |
(void) address_get(link, address, &existing);
|
|
|
2aacef |
|
|
|
2aacef |
- if (address->lifetime_valid_usec == 0)
|
|
|
2aacef |
+ if (address->lifetime_valid_usec == 0) {
|
|
|
2aacef |
+ if (consume_object)
|
|
|
2aacef |
+ address_free(address);
|
|
|
2aacef |
+
|
|
|
2aacef |
/* The requested address is outdated. Let's remove it. */
|
|
|
2aacef |
return address_remove_and_drop(existing);
|
|
|
2aacef |
+ }
|
|
|
2aacef |
|
|
|
2aacef |
if (!existing) {
|
|
|
2aacef |
_cleanup_(address_freep) Address *tmp = NULL;
|
|
|
2aacef |
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
|
|
|
2aacef |
index d1f3bab092..5214a8ad2c 100644
|
|
|
2aacef |
--- a/src/network/networkd-route.c
|
|
|
2aacef |
+++ b/src/network/networkd-route.c
|
|
|
2aacef |
@@ -1437,9 +1437,13 @@ int link_request_route(
|
|
|
2aacef |
|
|
|
2aacef |
(void) route_get(link->manager, link, route, &existing);
|
|
|
2aacef |
|
|
|
2aacef |
- if (route->lifetime_usec == 0)
|
|
|
2aacef |
+ if (route->lifetime_usec == 0) {
|
|
|
2aacef |
+ if (consume_object)
|
|
|
2aacef |
+ route_free(route);
|
|
|
2aacef |
+
|
|
|
2aacef |
/* The requested route is outdated. Let's remove it. */
|
|
|
2aacef |
return route_remove_and_drop(existing);
|
|
|
2aacef |
+ }
|
|
|
2aacef |
|
|
|
2aacef |
if (!existing) {
|
|
|
2aacef |
_cleanup_(route_freep) Route *tmp = NULL;
|