net/colo: fix g_hash_table_destroy assertion on uninitialized filter
PATCH 1/1 net/colo: fix g_hash_table_destroy assertion on uninitialized filter
From: Marc-André Lureau <[email protected]>
colo_rewriter_cleanup() unconditionally destroys connection_track_table, but the table is only allocated in colo_rewriter_setup(). When the filter-rewriter object is finalized without having been set up (e.g. during qom-test property enumeration), the pointer is NULL and g_hash_table_destroy() fires an assertion.
Use g_clear_pointer() to skip the destroy when the table was never initialized.
--- net/filter-rewriter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/filter-rewriter.c +1 -1
@@ -373,7 +373,7 @@ static void colo_rewriter_cleanup(NetFilterState *nf)g_free (s->incoming_queue); } -g_hash_table_destroy (s->connection_track_table); +g_clear_pointer (&s->connection_track_table, g_hash_table_destroy); }static void colo_rewriter_setup (NetFilterState *nf,Error **errp)
Signature · 1 line
2.55.0
Quoted 9 lines · On Thu, Jul 9, 2026 at 7:13 PM <[email protected]> wrote:
From: Marc-André Lureau <[email protected]>
colo_rewriter_cleanup()unconditionally destroysconnection_track_table, but the table is only allocated incolo_rewriter_setup(). When the filter-rewriter object is finalized without having been set up (e.g. during qom-test property enumeration), the pointer is NULL andg_hash_table_destroy()fires an assertion.
Quoted 4 lines
Use
g_clear_pointer()to skip the destroy when the table was never initialized.Signed-off-by Marc-Andre Lureau <[email protected]>
Looks good to me.
Are you working for filter-rewriter's qom-test?
There is no place in the current implementation where this issue would be triggered.
Quoted 20 lines
--- net/filter-rewriter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/filter-rewriter.c +1
-2@@ -373,7 +373,7 @@ static void colo_rewriter_cleanup(NetFilterState *nf)g_free (s->incoming_queue); } -g_hash_table_destroy (s->connection_track_table); +g_clear_pointer (&s->connection_track_table, g_hash_table_destroy); }static void colo_rewriter_setup (NetFilterState *nf,Error **errp) --2.55.0