Skip to content

Commit 10d93a9

Browse files
ujfalusibroonie
authored andcommitted
ASoC: SOF: imx: imx8: 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: 202acc5 ("ASoC: SOF: imx: Add i.MX8 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-5-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ac4dfcc commit 10d93a9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,14 @@ static int imx8_remove(struct snd_sof_dev *sdev)
365365
/* on i.MX8 there is 1 to 1 match between type and BAR idx */
366366
static int imx8_get_bar_index(struct snd_sof_dev *sdev, u32 type)
367367
{
368-
return type;
368+
/* Only IRAM and SRAM bars are valid */
369+
switch (type) {
370+
case SOF_FW_BLK_TYPE_IRAM:
371+
case SOF_FW_BLK_TYPE_SRAM:
372+
return type;
373+
default:
374+
return -EINVAL;
375+
}
369376
}
370377

371378
static void imx8_ipc_msg_data(struct snd_sof_dev *sdev,

0 commit comments

Comments
 (0)