Skip to content

Commit d9be4a8

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: imx: imx8m: Bar index is only valid for IRAM and SRAM types
i.MX8 only uses SOF_FW_BLK_TYPE_IRAM (1) and SOF_FW_BLK_TYPE_SRAM (3) bars, everything else is left as 0 in sdev->bar[] array. If a broken or purposefully crafted firmware image is loaded with other types of FW_BLK_TYPE then a kernel crash can be triggered. Make sure that only IRAM/SRAM type is converted to bar index. Fixes: afb93d7 ("ASoC: SOF: imx: Add i.MX8M HW support") Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Daniel Baluta <daniel.baluta@gmail.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Link: https://lore.kernel.org/r/20210915122116.18317-6-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 10d93a9 commit d9be4a8

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎sound/soc/sof/imx/imx8m.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,14 @@ static int imx8m_remove(struct snd_sof_dev *sdev)
228228
/* on i.MX8 there is 1 to 1 match between type and BAR idx */
229229
static int imx8m_get_bar_index(struct snd_sof_dev *sdev, u32 type)
230230
{
231-
return type;
231+
/* Only IRAM and SRAM bars are valid */
232+
switch (type) {
233+
case SOF_FW_BLK_TYPE_IRAM:
234+
case SOF_FW_BLK_TYPE_SRAM:
235+
return type;
236+
default:
237+
return -EINVAL;
238+
}
232239
}
233240

234241
static void imx8m_ipc_msg_data(struct snd_sof_dev *sdev,

0 commit comments

Comments
 (0)