Skip to content

Commit 83ffb38

Browse files
author
Dan Carpenter
committed
struct_assignment: fix returns_zeroed_mem() for fake assignments
If you have a struct within a struct like "foo.bar.baz" then an assignment gets translated into a series of fake assignments: foo.bar = fake assign(); The returns_zeroed_mem() doesn't says "fake assign();" does not return zeroed mem, but it should instead look at the kzalloc() that is being faked. Signed-off-by: Dan Carpenter <[email protected]>
1 parent 5e24569 commit 83ffb38

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

smatch_struct_assignment.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,21 @@ static void __struct_members_copy(int mode, struct expression *faked,
307307

308308
static int returns_zeroed_mem(struct expression *expr)
309309
{
310+
struct expression *tmp;
310311
char *fn;
311312

312313
if (expr->type != EXPR_CALL || expr->fn->type != EXPR_SYMBOL)
313314
return 0;
315+
316+
if (is_fake_call(expr)) {
317+
tmp = get_faked_expression();
318+
if (!tmp || tmp->type != EXPR_ASSIGNMENT || tmp->op != '=')
319+
return 0;
320+
expr = tmp->right;
321+
if (expr->type != EXPR_CALL || expr->fn->type != EXPR_SYMBOL)
322+
return 0;
323+
}
324+
314325
fn = expr_to_var(expr->fn);
315326
if (!fn)
316327
return 0;

0 commit comments

Comments
 (0)