From patchwork Mon Jun 10 10:12:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 1112992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Mppc3v8Cz9sBp; Mon, 10 Jun 2019 20:12:24 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1haHHq-0001HE-0h; Mon, 10 Jun 2019 10:12:22 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1haHHp-0001H2-1d for fwts-devel@lists.ubuntu.com; Mon, 10 Jun 2019 10:12:21 +0000 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1haHHo-0006yg-Lb; Mon, 10 Jun 2019 10:12:20 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH][V2] fwts_summary: check for list creation failure Date: Mon, 10 Jun 2019 11:12:20 +0100 Message-Id: <20190610101220.27222-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Colin Ian King Check for null pointer when creating a new list. Addresses-Coverity: ("Dereference null return") Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Ivan Hu --- src/lib/src/fwts_summary.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/src/fwts_summary.c b/src/lib/src/fwts_summary.c index 625dcd2d..041df5ad 100644 --- a/src/lib/src/fwts_summary.c +++ b/src/lib/src/fwts_summary.c @@ -233,6 +233,11 @@ int fwts_summary_report(fwts_framework *fw, fwts_list *test_list) fwts_list_link *item; fwts_list *sorted = fwts_list_new(); + if (!sorted) { + fwts_log_error(fw, "Out of memory allocating test summary list"); + return FWTS_ERROR; + } + fwts_list_foreach(item, test_list) fwts_list_add_ordered(sorted, fwts_list_data(fwts_framework_test *,item), fwts_framework_compare_test_name);