[v4,1/1] eal/unix: fix firmware reading with external xz helper

Message ID 20230926144454.13419-1-syalavarthi@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v4,1/1] eal/unix: fix firmware reading with external xz helper |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-sample-apps-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Srikanth Yalavarthi Sept. 26, 2023, 2:44 p.m. UTC
  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(-)
  

Comments

David Marchand Sept. 27, 2023, 8:20 a.m. UTC | #1
On Tue, Sep 26, 2023 at 4:45 PM Srikanth Yalavarthi
<syalavarthi@marvell.com> wrote:
>
> 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>

Reviewed-by: David Marchand <david.marchand@redhat.com>
  
David Marchand Sept. 27, 2023, 9:35 a.m. UTC | #2
Unaddressed
On Wed, Sep 27, 2023 at 10:20 AM David Marchand
<david.marchand@redhat.com> wrote:
> On Tue, Sep 26, 2023 at 4:45 PM Srikanth Yalavarthi
> <syalavarthi@marvell.com> wrote:
> >
> > 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>
>
> Reviewed-by: David Marchand <david.marchand@redhat.com>

Applied, thanks.
  

Patch

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