From 25b3cb77e1215ab08409e716769f61dc47ea6eef Mon Sep 17 00:00:00 2001 From: Tim Kourt Date: Wed, 23 Oct 2019 13:24:01 -0700 Subject: [PATCH] hwsim: Fix potential memory leak If msg has multiple RADIO NAME attributes, memory leak occurs. Note that this doesn't happen in practice. --- tools/hwsim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/hwsim.c b/tools/hwsim.c index e9ba1f95..500762db 100644 --- a/tools/hwsim.c +++ b/tools/hwsim.c @@ -312,11 +312,12 @@ static void list_callback(struct l_genl_msg *msg, void *user_data) break; case HWSIM_ATTR_RADIO_NAME: - hwname = l_malloc(len + 1); - if (hwname) { + if (!hwname) { + hwname = l_new(char, len + 1); + strncpy(hwname, data, len); - hwname[len] = '\0'; } + break; default: