All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: smatch@vger.kernel.org
Subject: Re: [PATCH 1/2] smatch_allocations: Record the function that allocates memory
Date: Tue, 16 Aug 2022 11:10:18 +0300	[thread overview]
Message-ID: <20220816081018.GP3438@kadam> (raw)
In-Reply-To: <226fb08b3a13fd24f0739ab63bff369718003119.1660580395.git.christophe.jaillet@wanadoo.fr>

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@wanadoo.fr>
> ---
> 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

      parent reply	other threads:[~2022-08-16 10:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 16:20 [PATCH 1/2] smatch_allocations: Record the function that allocates memory Christophe JAILLET
2022-08-15 16:21 ` [PATCH 2/2] check_freeing_devm: Take advantage of the new add_allocation hook Christophe JAILLET
2022-08-16  8:12   ` Dan Carpenter
2022-08-16  8:10 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220816081018.GP3438@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=smatch@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.