hwsim: Fix potential memory leak

If msg has multiple RADIO NAME attributes, memory leak occurs.

Note that this doesn't happen in practice.
This commit is contained in:
Tim Kourt 2019-10-23 13:24:01 -07:00 committed by Denis Kenzior
parent b096c27377
commit 25b3cb77e1
1 changed files with 4 additions and 3 deletions

View File

@ -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: