public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Faust <dfaust@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5843] bpf: avoid potential NULL pointer dereference
Date: Wed,  8 Dec 2021 18:48:50 +0000 (GMT)	[thread overview]
Message-ID: <20211208184850.270503858003@sourceware.org> (raw)

https://gcc.gnu.org/g:e4c2b55b4cefc574a4c2b0b06928220edb9b3f2c

commit r12-5843-ge4c2b55b4cefc574a4c2b0b06928220edb9b3f2c
Author: David Faust <david.faust@oracle.com>
Date:   Tue Dec 7 11:45:48 2021 -0800

    bpf: avoid potential NULL pointer dereference
    
    If the result from SSA_NAME_DEF_STMT is NULL, we could try to
    dereference it anyway and ICE. Avoid this.
    
    gcc/ChangeLog:
    
            * config/bpf/bpf.c (handle_attr_preserve): Avoid calling
            is_gimple_assign with a NULL pointer.

Diff:
---
 gcc/config/bpf/bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/bpf/bpf.c b/gcc/config/bpf/bpf.c
index 9d2c0bb6818..c054c1ead6b 100644
--- a/gcc/config/bpf/bpf.c
+++ b/gcc/config/bpf/bpf.c
@@ -1482,7 +1482,7 @@ handle_attr_preserve (function *fn)
 		      && TREE_CODE (TREE_OPERAND (expr, 0)) == SSA_NAME)
 		    {
 		      gimple *def_stmt = SSA_NAME_DEF_STMT (TREE_OPERAND (expr, 0));
-		      if (is_gimple_assign (def_stmt))
+		      if (def_stmt && is_gimple_assign (def_stmt))
 			expr = gimple_assign_rhs1 (def_stmt);
 		    }


                 reply	other threads:[~2021-12-08 18:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211208184850.270503858003@sourceware.org \
    --to=dfaust@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).