Smatch (Semantic Matching Tool) development
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Thomas Fourier <fourier.thomas@gmail.com>
Cc: smatch@vger.kernel.org
Subject: Re: [PATCH smatch] Add safety checks in various modules
Date: Thu, 15 Oct 2026 14:38:11 +0300	[thread overview]
Message-ID: <atC7I0WrKbNI-0ij@stanley.mountain> (raw)
In-Reply-To: <20261006132038.42445-3-fourier.thomas@gmail.com>

On Tue, Oct 06, 2026 at 03:20:40PM +0200, Thomas Fourier wrote:
> diff --git a/smatch_math.c b/smatch_math.c
> index ecb911a2..f5e88bdd 100644
> --- a/smatch_math.c
> +++ b/smatch_math.c
> @@ -69,6 +69,8 @@ static bool last_stmt_rl(struct statement *stmt, int implied, int *recurse_cnt,
>  		return false;
>  
>  	stmt = last_ptr_list((struct ptr_list *)stmt->stmts);
> +	if (!stmt)
> +		return false;
>  	if (stmt->type == STMT_LABEL) {
>  		if (stmt->label_statement &&
>  		    stmt->label_statement->type == STMT_EXPRESSION)
> @@ -1979,6 +1981,9 @@ int get_value(struct expression *expr, sval_t *res_sval)
>  	sval_t sval = {};
>  	int i;
>  
> +	if (!expr || expr->type >= NUM_EXPRESSION)

This could only happen if there is memory corruption so it's really just
a bandaid fix.

Anyway, applied.  Thanks!

regards,
dan carpenter


      reply	other threads:[~2026-10-15 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 13:20 [PATCH smatch] Add safety checks in various modules Thomas Fourier
2026-10-15 11:38 ` 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=atC7I0WrKbNI-0ij@stanley.mountain \
    --to=error27@gmail.com \
    --cc=fourier.thomas@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox