Powered by Linux
Re: [PATCH 1/2] smatch_allocations: Record the function that allocates memory — Semantic Matching Tool

Re: [PATCH 1/2] smatch_allocations: Record the function that allocates memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 15, 2022 at 06:20:55PM +0200, Christophe JAILLET wrote:
> Keep track of the name of the function that did the memory allocation.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
> ---
> Not sure if it is the best way to save this information. Maybe it can
> already be retrieved another way (from expr directly?)
> 

You could get it from the expr.  The expr is an assign expr

	foo = kmalloc(sizeof(*foo), GFP_KERNEL);

So you could do:

	while (expr->type == EXPR_ASSIGNMENT)
		expr = strip_expr(expr->right);

	if (expr->type != EXPR_CALL)
		return;

	name = expr_to_str(expr->fn);

At the same time putting it in the allocation_info feels like it might
be the right thing and it's basically no cost so I'm going to apply this.

regards,
dan carpenter




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux