diff mbox

[2/2] sparse, llvm: don't compile erroneous code

Message ID 1349738279-13253-2-git-send-email-j.neuschaefer@gmx.net (mailing list archive)
State Rejected, archived
Headers show

Commit Message

J. Neuschäfer Oct. 8, 2012, 11:17 p.m. UTC
If sparse emits an error message while parsing a file, don't
generate LLVM code, and also don't parse further files. This
prevents a segfault when sparse-llvm is fed with certain junk.

Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
---
 sparse-llvm.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Pekka Enberg Oct. 9, 2012, 6:30 a.m. UTC | #1
On Tue, Oct 9, 2012 at 2:17 AM, Jonathan Neuschäfer
<j.neuschaefer@gmx.net> wrote:
> If sparse emits an error message while parsing a file, don't
> generate LLVM code, and also don't parse further files. This
> prevents a segfault when sparse-llvm is fed with certain junk.
>
> Cc: Pekka Enberg <penberg@kernel.org>
> Cc: Christopher Li <sparse@chrisli.org>
> Cc: Jeff Garzik <jgarzik@redhat.com>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Acked-by: Pekka Enberg <penberg@kernel.org>

Chris, this depends on the first patch so please just take this
directly to your tree.
--
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/sparse-llvm.c b/sparse-llvm.c
index e4929e9..0fc0dae 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -1268,7 +1268,10 @@  int main(int argc, char **argv)
 	compile(module, sparse_initialize(argc, argv, &filelist));
 
 	FOR_EACH_PTR_NOTAG(filelist, file) {
-		compile(module, sparse(file));
+		struct symbol_list *symlist = sparse(file);
+		if (error_happened)
+			break;
+		compile(module, symlist);
 	} END_FOR_EACH_PTR_NOTAG(file);
 
 	LLVMVerifyModule(module, LLVMPrintMessageAction, NULL);