From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C781342644 for ; Tue, 26 Sep 2023 16:45:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FAEE402E4; Tue, 26 Sep 2023 16:45:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 5F8DE40269; Tue, 26 Sep 2023 16:45:01 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38Q6gktD032209; Tue, 26 Sep 2023 07:45:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=CdeeUB/k5EIPcfFP+eOw+PpZcQqZzBChrgi7pstkNpM=; b=izREWS0bYII4RKVFJ1A/CewdZcB9lTTqI3mwNHp7ciavUgVrmBsQ9EgZT5MnQNNZ1DbN n6t7lbgR29Msu8IoUQIiSt/mtF/ApaE3sfznaqfW7CmRp7+VnvYktDTxqTUxM2CG6QsQ LWWanTgacHi0BANkMn62klmbL4PkBLtgHQxzcR0BuemwBoDzAMaLW8ZRtXpC5pb6IyA4 JA+Azh2Fu2U0GmbkwMzqyY2B69NK2ES9rRfeA43AN7JJTgp7WqOcR8jLqF0hR8orvp3A 5OKhxbX/x1mB9ZemHapeyb3WY/evJj/Xc5MzSI6vAcuQUQBLgW5j76FIu5elvSzJO3IQ 9A== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3t9yhm1de1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 26 Sep 2023 07:45:00 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 26 Sep 2023 07:44:57 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 26 Sep 2023 07:44:57 -0700 Received: from ml-host-33.caveonetworks.com (unknown [10.110.143.233]) by maili.marvell.com (Postfix) with ESMTP id 4243E3F70A6; Tue, 26 Sep 2023 07:44:56 -0700 (PDT) From: Srikanth Yalavarthi To: Aaron Conole , Igor Russkikh , David Marchand CC: , , , , , , Subject: [PATCH v4 1/1] eal/unix: fix firmware reading with external xz helper Date: Tue, 26 Sep 2023 07:44:54 -0700 Message-ID: <20230926144454.13419-1-syalavarthi@marvell.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230922165356.31567-1-syalavarthi@marvell.com> References: <20230922165356.31567-1-syalavarthi@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: d78VlAB09PrbBoyubIW2MSilHzFwElRH X-Proofpoint-ORIG-GUID: d78VlAB09PrbBoyubIW2MSilHzFwElRH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-26_11,2023-09-26_01,2023-05-22_02 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org libarchive may support xz decompression only through an external (slower) helper. In such a case, archive_read_support_filter_xz() returns ARCHIVE_WARN. Fixes: 40edb9c0d36b ("eal: handle compressed firmware") Cc: stable@dpdk.org Signed-off-by: Srikanth Yalavarthi --- v4: * updated commit message * fixed checking archive_read_next_header v3: * removed gerrit change-id v2: * updated code as per review comments lib/eal/unix/eal_firmware.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/eal/unix/eal_firmware.c b/lib/eal/unix/eal_firmware.c index d1616b0bd9..1a7cf8e7b7 100644 --- a/lib/eal/unix/eal_firmware.c +++ b/lib/eal/unix/eal_firmware.c @@ -25,19 +25,31 @@ static int firmware_open(struct firmware_read_ctx *ctx, const char *name, size_t blocksize) { struct archive_entry *e; + int err; ctx->a = archive_read_new(); if (ctx->a == NULL) return -1; - if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK || - archive_read_support_filter_xz(ctx->a) != ARCHIVE_OK || - archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK || - archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) { - archive_read_free(ctx->a); - ctx->a = NULL; - return -1; - } + + if (archive_read_support_format_raw(ctx->a) != ARCHIVE_OK) + goto error; + + err = archive_read_support_filter_xz(ctx->a); + if (err != ARCHIVE_OK && err != ARCHIVE_WARN) + goto error; + + if (archive_read_open_filename(ctx->a, name, blocksize) != ARCHIVE_OK) + goto error; + + if (archive_read_next_header(ctx->a, &e) != ARCHIVE_OK) + goto error; + return 0; + +error: + archive_read_free(ctx->a); + ctx->a = NULL; + return -1; } static ssize_t -- 2.41.0