Skip to content
Snippets Groups Projects
Commit 5788c450 authored by Shengjiu Wang's avatar Shengjiu Wang
Browse files

LF-4300: ASoC: fsl_sai: Fix KASAN slab-out-of-bounds isuue


The regmap_config.max_register should match with
regmap_config.reg_defaults definition, otherwise:

[    5.007222] ==================================================================
[    5.014592] BUG: KASAN: slab-out-of-bounds in regcache_flat_init+0xd0/0x120
[    5.021635] Write of size 4 at addr ffff00000ab1d500 by task swapper/0/1
[    5.028397]
[    5.029954] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.10.52-03729-gd820c2b9c5b0 #824
[    5.037944] Hardware name: NXP i.MX8ULP EVK (DT)
[    5.042615] Call trace:
[    5.045142]  dump_backtrace+0x0/0x2b4
[    5.048884]  show_stack+0x18/0x24
[    5.052275]  dump_stack+0xfc/0x168
[    5.055757]  print_address_description.constprop.0+0x6c/0x488
[    5.061594]  kasan_report+0x118/0x210
[    5.065329]  __asan_store4+0x98/0xd4
[    5.068985]  regcache_flat_init+0xd0/0x120
[    5.073158]  regcache_init+0x33c/0x72c
[    5.076982]  __regmap_init+0xdf8/0x1730
[    5.080896]  __devm_regmap_init+0x70/0xc4
[    5.084980]  __devm_regmap_init_mmio_clk+0xd8/0x120
[    5.089956]  fsl_sai_probe+0x1c0/0xaf0
[    5.093784]  platform_drv_probe+0x70/0xd0
[    5.097863]  really_probe+0x148/0x704
[    5.101595]  driver_probe_device+0x78/0xec
[    5.105762]  device_driver_attach+0x118/0x120
[    5.110197]  __driver_attach+0xb0/0x190
[    5.114099]  bus_for_each_dev+0xe8/0x160
[    5.118092]  driver_attach+0x34/0x44
[    5.121736]  bus_add_driver+0x1b8/0x2c0
[    5.125641]  driver_register+0xe0/0x210
[    5.129552]  __platform_driver_register+0x80/0x90
[    5.134341]  fsl_sai_driver_init+0x1c/0x28
[    5.138512]  do_one_initcall+0xa8/0x260
[    5.142429]  kernel_init_freeable+0x2cc/0x350
[    5.146859]  kernel_init+0x14/0x12c
[    5.150420]  ret_from_fork+0x10/0x38

Fixes: 722eaf74 ("MLK-25556-7: ASoC: fsl_sai: add max_register in soc data")
Signed-off-by: default avatarShengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Reported-by: default avatarJason Liu <jason.hui.liu@nxp.com>
Acked-by: default avatarJason Liu <jason.hui.liu@nxp.com>
parent 601af951
No related branches found
No related tags found
No related merge requests found
...@@ -1328,10 +1328,10 @@ static int fsl_sai_probe(struct platform_device *pdev) ...@@ -1328,10 +1328,10 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (sai->soc_data->reg_offset == 8) { if (sai->soc_data->reg_offset == 8) {
fsl_sai_regmap_config.reg_defaults = fsl_sai_reg_defaults_ofs8; fsl_sai_regmap_config.reg_defaults = fsl_sai_reg_defaults_ofs8;
fsl_sai_regmap_config.max_register = FSL_SAI_MDIV;
fsl_sai_regmap_config.num_reg_defaults = fsl_sai_regmap_config.num_reg_defaults =
ARRAY_SIZE(fsl_sai_reg_defaults_ofs8); ARRAY_SIZE(fsl_sai_reg_defaults_ofs8);
} }
fsl_sai_regmap_config.max_register = sai->soc_data->max_register;
sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev, sai->regmap = devm_regmap_init_mmio_clk(&pdev->dev,
NULL, base, &fsl_sai_regmap_config); NULL, base, &fsl_sai_regmap_config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment