diff mbox

[1/6] ASoC: sigmadsp: Refuse to load firmware files with a non-supported version

Message ID 1416418148-14803-1-git-send-email-lars@metafoo.de (mailing list archive)
State Accepted
Commit 50c0f21b42dd4cd02b51f82274f66912d9a7fa32
Headers show

Commit Message

Lars-Peter Clausen Nov. 19, 2014, 5:29 p.m. UTC
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>
Cc: stable@vger.kernel.org
---
 sound/soc/codecs/sigmadsp.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Mark Brown Nov. 20, 2014, 9:56 a.m. UTC | #1
On Wed, Nov 19, 2014 at 06:29:02PM +0100, Lars-Peter Clausen wrote:
> 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.

Applied all, thanks.
diff mbox

Patch

diff --git a/sound/soc/codecs/sigmadsp.c b/sound/soc/codecs/sigmadsp.c
index f2de7e0..81a38dd 100644
--- a/sound/soc/codecs/sigmadsp.c
+++ b/sound/soc/codecs/sigmadsp.c
@@ -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);