patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Srikanth Yalavarthi <syalavarthi@marvell.com>
To: Aaron Conole <aconole@redhat.com>,
	Igor Russkikh <irusskikh@marvell.com>,
	 David Marchand <david.marchand@redhat.com>
Cc: <dev@dpdk.org>, <syalavarthi@marvell.com>,
	<sshankarnara@marvell.com>, <aprabhu@marvell.com>,
	<ptakkar@marvell.com>, <jerinjacobk@gmail.com>, <stable@dpdk.org>
Subject: [PATCH v4 1/1] eal/unix: fix firmware reading with external xz helper
Date: Tue, 26 Sep 2023 07:44:54 -0700	[thread overview]
Message-ID: <20230926144454.13419-1-syalavarthi@marvell.com> (raw)
In-Reply-To: <20230922165356.31567-1-syalavarthi@marvell.com>

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 <syalavarthi@marvell.com>
---
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


  parent reply	other threads:[~2023-09-26 14:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22 16:53 [PATCH 1/1] eal: enable xz read support and ignore warning Srikanth Yalavarthi
2023-09-25  9:10 ` David Marchand
2023-09-26 13:32   ` [EXT] " Srikanth Yalavarthi
2023-09-26 13:30 ` [PATCH v2 1/1] eal: update " Srikanth Yalavarthi
2023-09-26 13:56   ` David Marchand
2023-09-26 14:47     ` [EXT] " Srikanth Yalavarthi
2023-09-26 13:49 ` [PATCH v3 " Srikanth Yalavarthi
2023-09-26 14:44 ` Srikanth Yalavarthi [this message]
2023-09-27  8:20   ` [PATCH v4 1/1] eal/unix: fix firmware reading with external xz helper David Marchand
2023-09-27  9:35     ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926144454.13419-1-syalavarthi@marvell.com \
    --to=syalavarthi@marvell.com \
    --cc=aconole@redhat.com \
    --cc=aprabhu@marvell.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=irusskikh@marvell.com \
    --cc=jerinjacobk@gmail.com \
    --cc=ptakkar@marvell.com \
    --cc=sshankarnara@marvell.com \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).