commit 25b3cb77e1215ab08409e716769f61dc47ea6eef
parent b096c27377233acc26f886188b61aebe644d3a11
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Wed, 23 Oct 2019 13:24:01 -0700
hwsim: Fix potential memory leak
If msg has multiple RADIO NAME attributes, memory leak occurs.
Note that this doesn't happen in practice.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git 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: