Check avl_insert() return value and free node data on error, otherwise this
is observed to directly leak memory.
Fixes: 6e3c6dcf922e ("kmodloader: add module alias awareness")
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
mn->avl.key = strcpy(_name, name);
mn->m = m;
mn->is_alias = is_alias;
- avl_insert(&modules, &mn->avl);
- m->refcnt += 1;
+ if (avl_insert(&modules, &mn->avl) == 0)
+ m->refcnt += 1;
+ else
+ free(mn);
}
return mn;
}