Skip to content

Commit 3b41574

Browse files
Amadeusz Sławińskibroonie
authored andcommitted
ASoC: Intel: avs: Fix NULL pointer dereference
Due to unfortunate interaction between two recent patchsets, avs driver ends up dereferencing NULL pointer when registering i2s boards. Commit [1] does a call to avs_mach_ssp_tdm() which requires mach->pdata, however due to another change in [2], mach->pdata is initialized after the call. Reshuffle code to initialise mach->pdata before calling avs_mach_ssp_tdm(). [1] Link: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/sound/soc/intel/avs?id=79138dbff53ab0e9891ebdfce8d7b298c3783cd1 [2] Link: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git/commit/sound/soc/intel/avs?id=7d859189de13f06fdc511761c745f3b302bed7b6 Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Acked-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250424094600.1678051-1-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 171eb6f commit 3b41574

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

sound/soc/intel/avs/board_selection.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,6 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_mach
472472
return -ENODEV;
473473
}
474474

475-
uid = mach->mach_params.i2s_link_mask;
476-
if (avs_mach_singular_ssp(mach))
477-
uid = (uid << AVS_CHANNELS_MAX) + avs_mach_ssp_tdm(mach, avs_mach_ssp_port(mach));
478-
479-
name = devm_kasprintf(adev->dev, GFP_KERNEL, "%s.%d-platform", mach->drv_name, uid);
480-
if (!name)
481-
return -ENOMEM;
482-
483475
pdata = mach->pdata;
484476
if (!pdata)
485477
pdata = devm_kzalloc(adev->dev, sizeof(*pdata), GFP_KERNEL);
@@ -488,6 +480,14 @@ static int avs_register_i2s_board(struct avs_dev *adev, struct snd_soc_acpi_mach
488480
pdata->obsolete_card_names = obsolete_card_names;
489481
mach->pdata = pdata;
490482

483+
uid = mach->mach_params.i2s_link_mask;
484+
if (avs_mach_singular_ssp(mach))
485+
uid = (uid << AVS_CHANNELS_MAX) + avs_mach_ssp_tdm(mach, avs_mach_ssp_port(mach));
486+
487+
name = devm_kasprintf(adev->dev, GFP_KERNEL, "%s.%d-platform", mach->drv_name, uid);
488+
if (!name)
489+
return -ENOMEM;
490+
491491
ret = avs_i2s_platform_register(adev, name, mach->mach_params.i2s_link_mask, pdata->tdms);
492492
if (ret < 0)
493493
return ret;

0 commit comments

Comments
 (0)