ASoC: sigmadsp: Refuse to load firmware files with a non-supported version
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 19 Nov 2014 17:29:02 +0000 (18:29 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 20 Nov 2014 09:55:29 +0000 (09:55 +0000)
Make sure to check the version field of the firmware header to make sure to
not accidentally try to parse a firmware file with a different layout.
Trying to do so can result in loading invalid firmware code to the device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Cc: stable@vger.kernel.org
sound/soc/codecs/sigmadsp.c

index f2de7e049bc6c6d3c2b83bcd6d1b616c9a771535..81a38dd9af1f7421653b713fedebe1113924e542 100644 (file)
@@ -159,6 +159,13 @@ int _process_sigma_firmware(struct device *dev,
                goto done;
        }
 
+       if (ssfw_head->version != 1) {
+               dev_err(dev,
+                       "Failed to load firmware: Invalid version %d. Supported firmware versions: 1\n",
+                       ssfw_head->version);
+               goto done;
+       }
+
        crc = crc32(0, fw->data + sizeof(*ssfw_head),
                        fw->size - sizeof(*ssfw_head));
        pr_debug("%s: crc=%x\n", __func__, crc);