]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: fireworks: bound device-supplied status before string array lookup
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Apr 2026 14:05:54 +0000 (16:05 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:30:45 +0000 (13:30 +0200)
commit 07704bbf36f57e4379e4cadf96410dab14621e3b upstream.

The status field in an EFW response is a 32-bit value supplied by the
firewire device.  efr_status_names[] has 17 entries so a status value
outside that range goes off into the weeds when looking at the %s value.

Even worse, the status could return EFR_STATUS_INCOMPLETE which is
0x80000000, and is obviously not in that array of potential strings.

Fix this up by properly bounding the index against the array size and
printing "unknown" if it's not recognized.

Cc: Clemens Ladisch <clemens@ladisch.de>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Fixes: bde8a8f23bbe ("ALSA: fireworks: Add transaction and some commands")
Cc: stable <stable@kernel.org>
Assisted-by: gregkh_clanker_t1000
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://patch.msgid.link/2026040953-astute-camera-1aa1@gregkh
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/firewire/fireworks/fireworks_command.c

index 2b595ee0bc357b378c1143a0fba96a74db6f9054..05550f36fac5515f5047cdd94aadf329d51700e8 100644 (file)
@@ -151,10 +151,13 @@ efw_transaction(struct snd_efw *efw, unsigned int category,
            (be32_to_cpu(header->category) != category) ||
            (be32_to_cpu(header->command) != command) ||
            (be32_to_cpu(header->status) != EFR_STATUS_OK)) {
+               u32 st = be32_to_cpu(header->status);
+
                dev_err(&efw->unit->device, "EFW command failed [%u/%u]: %s\n",
                        be32_to_cpu(header->category),
                        be32_to_cpu(header->command),
-                       efr_status_names[be32_to_cpu(header->status)]);
+                       st < ARRAY_SIZE(efr_status_names) ?
+                               efr_status_names[st] : "unknown");
                err = -EIO;
                goto end;
        }