diff mbox

avoid crash with test-linearize -vv

Message ID 20170319180118.83953-1-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck March 19, 2017, 6:01 p.m. UTC
When verbose is set to 2 or higher, show_instruction()
also display removed instructions. Some of these instructions
can have their associated symbol removed and set to NULL
which will cause a crash with 'test-linearize -vv'.

Fix this by avoiding to dereference symbol's details of
removed instructions.
---
 linearize.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Christopher Li March 24, 2017, 3:03 a.m. UTC | #1
On Sun, Mar 19, 2017 at 11:01 AM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> When verbose is set to 2 or higher, show_instruction()
> also display removed instructions. Some of these instructions
> can have their associated symbol removed and set to NULL
> which will cause a crash with 'test-linearize -vv'.
>
> Fix this by avoiding to dereference symbol's details of
> removed instructions.

I like to apply it. Can you add SOB?

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luc Van Oostenryck March 24, 2017, 7:49 a.m. UTC | #2
On Thu, Mar 23, 2017 at 08:03:36PM -0700, Christopher Li wrote:
> On Sun, Mar 19, 2017 at 11:01 AM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > When verbose is set to 2 or higher, show_instruction()
> > also display removed instructions. Some of these instructions
> > can have their associated symbol removed and set to NULL
> > which will cause a crash with 'test-linearize -vv'.
> >
> > Fix this by avoiding to dereference symbol's details of
> > removed instructions.
> 
> I like to apply it. Can you add SOB?

Sure.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/linearize.c b/linearize.c
index 4ebd6d6d8..1bbada887 100644
--- a/linearize.c
+++ b/linearize.c
@@ -319,6 +319,8 @@  const char *show_instruction(struct instruction *insn)
 		struct symbol *sym = insn->symbol->sym;
 		buf += sprintf(buf, "%s <- ", show_pseudo(insn->target));
 
+		if (!insn->bb && !sym)
+			break;
 		if (sym->bb_target) {
 			buf += sprintf(buf, ".L%u", sym->bb_target->nr);
 			break;