From patchwork Mon Oct 8 23:17:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=2E_Neusch=C3=A4fer?= X-Patchwork-Id: 1567451 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C0A733FC1A for ; Mon, 8 Oct 2012 23:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751845Ab2JHXSl (ORCPT ); Mon, 8 Oct 2012 19:18:41 -0400 Received: from mailout-de.gmx.net ([213.165.64.22]:59977 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751645Ab2JHXSl (ORCPT ); Mon, 8 Oct 2012 19:18:41 -0400 Received: (qmail invoked by alias); 08 Oct 2012 23:18:39 -0000 Received: from dslb-084-060-229-125.pools.arcor-ip.net (EHLO debian.debian) [84.60.229.125] by mail.gmx.net (mp004) with SMTP; 09 Oct 2012 01:18:39 +0200 X-Authenticated: #41721828 X-Provags-ID: V01U2FsdGVkX18nBDJkuo4nTNApx9p00YiNGSRpy3LG2+YkHkgKBB mCCncBTwLE2m1g From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= To: linux-sparse@vger.kernel.org Cc: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Pekka Enberg , Christopher Li , Jeff Garzik , Linus Torvalds Subject: [PATCH 2/2] sparse, llvm: don't compile erroneous code Date: Tue, 9 Oct 2012 01:17:58 +0200 Message-Id: <1349738279-13253-2-git-send-email-j.neuschaefer@gmx.net> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1349738279-13253-1-git-send-email-j.neuschaefer@gmx.net> References: <1349738279-13253-1-git-send-email-j.neuschaefer@gmx.net> MIME-Version: 1.0 X-Y-GMX-Trusted: 0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org 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 Cc: Christopher Li Cc: Jeff Garzik Cc: Linus Torvalds Signed-off-by: Jonathan Neuschäfer Acked-by: Pekka Enberg --- sparse-llvm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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);