Print this page
smatch: check libld_* allocation functions
*** 44,60 ****
STATE(allocated);
STATE(ok);
static void set_parent(struct expression *expr, struct smatch_state *state);
- static const char *allocation_funcs[] = {
- "malloc",
- "kmalloc",
- "kzalloc",
- "kmemdup",
- };
-
static char *alloc_parent_str(struct symbol *sym)
{
static char buf[256];
if (!sym || !sym->ident)
--- 44,53 ----
*** 251,266 ****
check_for_allocated();
}
void check_leaks(int id)
{
- int i;
-
my_id = id;
! for (i = 0; i < ARRAY_SIZE(allocation_funcs); i++)
! add_function_assign_hook(allocation_funcs[i], &match_alloc, NULL);
add_hook(&match_condition, CONDITION_HOOK);
add_hook(&match_function_call, FUNCTION_CALL_HOOK);
add_hook(&match_assign, ASSIGNMENT_HOOK);
--- 244,269 ----
check_for_allocated();
}
void check_leaks(int id)
{
my_id = id;
! switch (option_project) {
! case PROJ_KERNEL:
! add_function_assign_hook("kmalloc", &match_alloc, NULL);
! add_function_assign_hook("kzalloc", &match_alloc, NULL);
! add_function_assign_hook("kmemdup", &match_alloc, NULL);
! break;
! case PROJ_ILLUMOS_USER:
! add_function_assign_hook("libld_malloc", &match_alloc, NULL);
! add_function_assign_hook("libld_calloc", &match_alloc, NULL);
! /* FALLTHROUGH */
! default:
! add_function_assign_hook("malloc", &match_alloc, NULL);
! add_function_assign_hook("calloc", &match_alloc, NULL);
! }
add_hook(&match_condition, CONDITION_HOOK);
add_hook(&match_function_call, FUNCTION_CALL_HOOK);
add_hook(&match_assign, ASSIGNMENT_HOOK);