* [PATCH 0/2] ASoC: sti: regmap_field usage improvements
@ 2026-02-20 15:26 Sander Vanheule
2026-02-20 15:26 ` [PATCH 1/2] ASoC: sti: Return errors from regmap_field_alloc() Sander Vanheule
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sander Vanheule @ 2026-02-20 15:26 UTC (permalink / raw)
To: Arnaud Pouliquen, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
Cc: linux-sound, linux-kernel, Sander Vanheule
uni_player_parse_dt_audio_glue() allocates two regmap_field objects on
the device's regmap. However, error codes from these allocations are not
propagated correctly and the resources will leak on device removal.
These issues were found while looking for users of regmap_field_alloc(),
to assess the impact of adding a cleanup helper for regmap_field. It
appears this driver is the only (remaining) in-tree user of this
allocator. Since the resources are long-lived, it may as well switch to
devm_regmap_field_alloc().
As I don't have access to this hardware, these patches were only compile
tested on a UM build.
Sander Vanheule (2):
ASoC: sti: Return errors from regmap_field_alloc()
ASoC: sti: use managed regmap_field allocations
sound/soc/sti/uniperif_player.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ASoC: sti: Return errors from regmap_field_alloc()
2026-02-20 15:26 [PATCH 0/2] ASoC: sti: regmap_field usage improvements Sander Vanheule
@ 2026-02-20 15:26 ` Sander Vanheule
2026-02-20 15:26 ` [PATCH 2/2] ASoC: sti: use managed regmap_field allocations Sander Vanheule
2026-03-03 11:20 ` [PATCH 0/2] ASoC: sti: regmap_field usage improvements Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Sander Vanheule @ 2026-02-20 15:26 UTC (permalink / raw)
To: Arnaud Pouliquen, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
Cc: linux-sound, linux-kernel, Sander Vanheule
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: 76c2145ded6b ("ASoC: sti: Add CPU DAI driver for playback")
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
sound/soc/sti/uniperif_player.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index 6d1ce030963c..f1b7e76f97b5 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -1029,7 +1029,12 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,
}
player->clk_sel = regmap_field_alloc(regmap, regfield[0]);
+ if (IS_ERR(player->clk_sel))
+ return PTR_ERR(player->clk_sel);
+
player->valid_sel = regmap_field_alloc(regmap, regfield[1]);
+ if (IS_ERR(player->valid_sel))
+ return PTR_ERR(player->valid_sel);
return 0;
}
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] ASoC: sti: use managed regmap_field allocations
2026-02-20 15:26 [PATCH 0/2] ASoC: sti: regmap_field usage improvements Sander Vanheule
2026-02-20 15:26 ` [PATCH 1/2] ASoC: sti: Return errors from regmap_field_alloc() Sander Vanheule
@ 2026-02-20 15:26 ` Sander Vanheule
2026-03-03 11:20 ` [PATCH 0/2] ASoC: sti: regmap_field usage improvements Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Sander Vanheule @ 2026-02-20 15:26 UTC (permalink / raw)
To: Arnaud Pouliquen, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
Cc: linux-sound, linux-kernel, Sander Vanheule
The regmap_field objects allocated at player init are never freed and
may leak resources if the driver is removed.
Switch to devm_regmap_field_alloc() to automatically limit the lifetime
of the allocations the lifetime of the device.
Fixes: 76c2145ded6b ("ASoC: sti: Add CPU DAI driver for playback")
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
sound/soc/sti/uniperif_player.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index f1b7e76f97b5..45d35b887e4e 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -1028,11 +1028,11 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,
return PTR_ERR(regmap);
}
- player->clk_sel = regmap_field_alloc(regmap, regfield[0]);
+ player->clk_sel = devm_regmap_field_alloc(&pdev->dev, regmap, regfield[0]);
if (IS_ERR(player->clk_sel))
return PTR_ERR(player->clk_sel);
- player->valid_sel = regmap_field_alloc(regmap, regfield[1]);
+ player->valid_sel = devm_regmap_field_alloc(&pdev->dev, regmap, regfield[1]);
if (IS_ERR(player->valid_sel))
return PTR_ERR(player->valid_sel);
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] ASoC: sti: regmap_field usage improvements
2026-02-20 15:26 [PATCH 0/2] ASoC: sti: regmap_field usage improvements Sander Vanheule
2026-02-20 15:26 ` [PATCH 1/2] ASoC: sti: Return errors from regmap_field_alloc() Sander Vanheule
2026-02-20 15:26 ` [PATCH 2/2] ASoC: sti: use managed regmap_field allocations Sander Vanheule
@ 2026-03-03 11:20 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-03-03 11:20 UTC (permalink / raw)
To: Arnaud Pouliquen, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Sander Vanheule
Cc: linux-sound, linux-kernel
On Fri, 20 Feb 2026 16:26:32 +0100, Sander Vanheule wrote:
> uni_player_parse_dt_audio_glue() allocates two regmap_field objects on
> the device's regmap. However, error codes from these allocations are not
> propagated correctly and the resources will leak on device removal.
>
> These issues were found while looking for users of regmap_field_alloc(),
> to assess the impact of adding a cleanup helper for regmap_field. It
> appears this driver is the only (remaining) in-tree user of this
> allocator. Since the resources are long-lived, it may as well switch to
> devm_regmap_field_alloc().
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: sti: Return errors from regmap_field_alloc()
commit: 272aabef50bc3fe58edd26de000f4cdd41bdbe60
[2/2] ASoC: sti: use managed regmap_field allocations
commit: 1696fad8b259a2d46e51cd6e17e4bcdbe02279fa
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-03-03 11:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-20 15:26 [PATCH 0/2] ASoC: sti: regmap_field usage improvements Sander Vanheule
2026-02-20 15:26 ` [PATCH 1/2] ASoC: sti: Return errors from regmap_field_alloc() Sander Vanheule
2026-02-20 15:26 ` [PATCH 2/2] ASoC: sti: use managed regmap_field allocations Sander Vanheule
2026-03-03 11:20 ` [PATCH 0/2] ASoC: sti: regmap_field usage improvements Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®