Skip to content

Commit e5c1e7e

Browse files
svanheulegregkh
authored andcommitted
ASoC: sti: Return errors from regmap_field_alloc()
[ Upstream commit 272aabe ] When regmap_field_alloc() fails, it can return an error. Specifically, it will return PTR_ERR(-ENOMEM) when the allocation returns a NULL pointer. The code then uses these allocations with a simple NULL check: if (player->clk_sel) { // May dereference invalid pointer (-ENOMEM) err = regmap_field_write(player->clk_sel, ...); } Ensure initialization fails by forwarding the errors from regmap_field_alloc(), thus avoiding the use of the invalid pointers. Fixes: 76c2145 ("ASoC: sti: Add CPU DAI driver for playback") Signed-off-by: Sander Vanheule <sander@svanheule.net> Link: https://patch.msgid.link/20260220152634.480766-2-sander@svanheule.net Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c319583 commit e5c1e7e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

sound/soc/sti/uniperif_player.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,12 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,
10291029
}
10301030

10311031
player->clk_sel = regmap_field_alloc(regmap, regfield[0]);
1032+
if (IS_ERR(player->clk_sel))
1033+
return PTR_ERR(player->clk_sel);
1034+
10321035
player->valid_sel = regmap_field_alloc(regmap, regfield[1]);
1036+
if (IS_ERR(player->valid_sel))
1037+
return PTR_ERR(player->valid_sel);
10331038

10341039
return 0;
10351040
}

0 commit comments

Comments
 (0)