ASoC: sigmadsp: Fix endianness conversion
authorLars-Peter Clausen <lars@metafoo.de>
Fri, 21 Nov 2014 17:53:52 +0000 (18:53 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 21 Nov 2014 18:17:50 +0000 (18:17 +0000)
Make sure to always convert the firmware data to local endianness before
using it.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: a35daac77a03 ("ASoC: sigmadsp: Add support for fw v2")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/sigmadsp.c

index 55af596935d4dc37ad9ba6614b310c70efa4aa02..6abefd27b86c6be9b065b0afdd3f2ca5e35ffb6c 100644 (file)
@@ -235,7 +235,7 @@ static int sigma_fw_load_control(struct sigmadsp *sigmadsp,
 
        ctrl->addr = le16_to_cpu(ctrl_chunk->addr);
        ctrl->num_bytes = num_bytes;
-       ctrl->samplerates = chunk->samplerates;
+       ctrl->samplerates = le32_to_cpu(chunk->samplerates);
 
        list_add_tail(&ctrl->head, &sigmadsp->ctrl_list);
 
@@ -266,7 +266,7 @@ static int sigma_fw_load_data(struct sigmadsp *sigmadsp,
 
        data->addr = le16_to_cpu(data_chunk->addr);
        data->length = length;
-       data->samplerates = chunk->samplerates;
+       data->samplerates = le32_to_cpu(chunk->samplerates);
        memcpy(data->data, data_chunk->data, length);
        list_add_tail(&data->head, &sigmadsp->data_list);
 
@@ -329,7 +329,7 @@ static int sigmadsp_fw_load_v2(struct sigmadsp *sigmadsp,
                if (length > fw->size - pos || length < sizeof(*chunk))
                        return -EINVAL;
 
-               switch (chunk->tag) {
+               switch (le32_to_cpu(chunk->tag)) {
                case SIGMA_FW_CHUNK_TYPE_DATA:
                        ret = sigma_fw_load_data(sigmadsp, chunk, length);
                        break;