From b5390e4bafefa975d090f3b516beae81de21b887 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 17 Mar 2009 11:04:32 +0300 Subject: [PATCH] check_memory: add kzalloc(), more complex variables. Signed-off-by: Dan Carpenter --- check_memory.c | 15 ++++++++------- validation/sm_implied3.c | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/check_memory.c b/check_memory.c index 1cf9c773..7cb961a2 100644 --- a/check_memory.c +++ b/check_memory.c @@ -33,6 +33,7 @@ struct tracker_list *arguments; static const char *allocation_funcs[] = { "malloc", "kmalloc", + "kzalloc", NULL, }; @@ -151,15 +152,15 @@ static int handle_double_assign(struct expression *expr) return 0; assign_seen++; - name = get_variable_from_expr(expr->left, &sym); + name = get_variable_from_expr_complex(expr->left, &sym); if (name && is_parent(expr->left)) assign_parent(sym); - name = get_variable_from_expr(expr->right->left, &sym); + name = get_variable_from_expr_complex(expr->right->left, &sym); if (name && is_parent(expr->right->left)) assign_parent(sym); - name = get_variable_from_expr(expr->right->right, &sym); + name = get_variable_from_expr_complex(expr->right->right, &sym); if (name && is_parent(expr->right->right)) assign_parent(sym); @@ -239,7 +240,7 @@ static void match_kfree(struct expression *expr) struct symbol *ptr_sym; ptr_expr = get_argument_from_call_expr(expr->args, 0); - ptr_name = get_variable_from_expr(ptr_expr, &ptr_sym); + ptr_name = get_variable_from_expr_complex(ptr_expr, &ptr_sym); if (is_freed(ptr_name, ptr_sym) && !is_null(ptr_name, ptr_sym)) { smatch_msg("error: double free of %s", ptr_name); } @@ -281,7 +282,7 @@ static void match_return(struct statement *stmt) char *name; struct symbol *sym; - name = get_variable_from_expr(stmt->ret_value, &sym); + name = get_variable_from_expr_complex(stmt->ret_value, &sym); if (sym) assign_parent(sym); free_string(name); @@ -319,7 +320,7 @@ static void match_condition(struct expression *expr) case EXPR_PREOP: case EXPR_SYMBOL: case EXPR_DEREF: - name = get_variable_from_expr(expr, &sym); + name = get_variable_from_expr_complex(expr, &sym); if (!name) return; set_new_true_false_paths(name, sym); @@ -352,7 +353,7 @@ static void match_function_call(struct expression *expr) FOR_EACH_PTR(expr->args, tmp) { tmp = strip_expr(tmp); - name = get_variable_from_expr(tmp, &sym); + name = get_variable_from_expr_complex(tmp, &sym); if (!name) continue; if ((state = get_sm_state(name, my_id, sym))) { diff --git a/validation/sm_implied3.c b/validation/sm_implied3.c index a52aa530..3dbad013 100644 --- a/validation/sm_implied3.c +++ b/validation/sm_implied3.c @@ -17,7 +17,7 @@ void func (void) if (c) {} - ab = kzalloc(); + ab = some_func(); if (NULL == ab) { ret = -1; goto foo; -- 2.11.4.GIT