* [PATCH 1/3] ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data()
2026-05-21 12:25 [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Richard Fitzgerald
@ 2026-05-21 12:25 ` Richard Fitzgerald
2026-05-21 12:25 ` [PATCH 2/3] ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup() Richard Fitzgerald
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Richard Fitzgerald @ 2026-05-21 12:25 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
When calculating data->count replace the incorrect sizeof(data) with use
of struct_offset().
The faulty sizeof(data) was incorrectly calculating the size of the
pointer instead of the size of the struct pointed to. As it happens, both
values are 8 on a 64-bit CPU. In the unlikely event of using this code on
a 32-bit CPU the number of available bytes would be calculated 4 larger
than is actually available.
Instead of changing to sizeof(*data) it has been replaced by
struct_offset() because it has better chance of detecting these sorts of
typos. Also the offset of the data[] array is actually what we want to know
here anyway.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 2b62e66626f0 ("ASoC: cs-amp-lib: Add function to write calibration to UEFI")
---
sound/soc/codecs/cs-amp-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c
index b34b1f5f121f..881c6f2264f3 100644
--- a/sound/soc/codecs/cs-amp-lib.c
+++ b/sound/soc/codecs/cs-amp-lib.c
@@ -500,7 +500,7 @@ static int _cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, i
* must be set.
*/
if (data->count == 0)
- data->count = (data->size - sizeof(data)) / sizeof(data->data[0]);
+ data->count = (data->size - struct_offset(data, data)) / sizeof(data->data[0]);
if (amp_index < 0) {
/* Is there already a slot for this target? */
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/3] ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup()
2026-05-21 12:25 [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Richard Fitzgerald
2026-05-21 12:25 ` [PATCH 1/3] ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data() Richard Fitzgerald
@ 2026-05-21 12:25 ` Richard Fitzgerald
2026-05-21 12:25 ` [PATCH 3/3] ASoC: cs-amp-lib: Fix typo in error message: write -> read Richard Fitzgerald
2026-05-21 14:13 ` [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Richard Fitzgerald @ 2026-05-21 12:25 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
Rewrite cs_amp_create_debugfs() so that dput() will be called on
a valid dentry returned from debugfs_lookup().
The pointer returned from debugfs_lookup() must be released by dput().
The pointer returned from debugfs_create_dir() does not need to be
passed to dput().
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: cdd27fa3298a ("ASoC: cs-amp-lib: Add helpers for factory calibration")
---
sound/soc/codecs/cs-amp-lib.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c
index 881c6f2264f3..e97a125ebbb3 100644
--- a/sound/soc/codecs/cs-amp-lib.c
+++ b/sound/soc/codecs/cs-amp-lib.c
@@ -833,11 +833,18 @@ EXPORT_SYMBOL_NS_GPL(cs_amp_devm_get_vendor_specific_variant_id, "SND_SOC_CS_AMP
*/
struct dentry *cs_amp_create_debugfs(struct device *dev)
{
- struct dentry *dir;
+ struct dentry *dir, *created;
+ /* debugfs_lookup() can return NULL or ERR_PTR on error */
dir = debugfs_lookup("cirrus_logic", NULL);
- if (!dir)
- dir = debugfs_create_dir("cirrus_logic", NULL);
+ if (!IS_ERR_OR_NULL(dir)) {
+ created = debugfs_create_dir(dev_name(dev), dir);
+ dput(dir);
+
+ return created;
+ }
+
+ dir = debugfs_create_dir("cirrus_logic", NULL);
return debugfs_create_dir(dev_name(dev), dir);
}
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 3/3] ASoC: cs-amp-lib: Fix typo in error message: write -> read
2026-05-21 12:25 [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Richard Fitzgerald
2026-05-21 12:25 ` [PATCH 1/3] ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data() Richard Fitzgerald
2026-05-21 12:25 ` [PATCH 2/3] ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup() Richard Fitzgerald
@ 2026-05-21 12:25 ` Richard Fitzgerald
2026-05-21 14:13 ` [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Richard Fitzgerald @ 2026-05-21 12:25 UTC (permalink / raw)
To: broonie; +Cc: linux-sound, linux-kernel, patches
Fix the error message in cs_amp_read_cal_coeff() to say "Failed to read".
It was incorrectly "Failed to write", probably a copy-paste error.
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
sound/soc/codecs/cs-amp-lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c
index e97a125ebbb3..fb5b950e584c 100644
--- a/sound/soc/codecs/cs-amp-lib.c
+++ b/sound/soc/codecs/cs-amp-lib.c
@@ -118,7 +118,7 @@ static int cs_amp_read_cal_coeff(struct cs_dsp *dsp,
}
if (ret < 0) {
- dev_err(dsp->dev, "Failed to write to '%s': %d\n", ctl_name, ret);
+ dev_err(dsp->dev, "Failed to read '%s': %d\n", ctl_name, ret);
return ret;
}
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes
2026-05-21 12:25 [PATCH 0/3] ASoC: cs-amp-lib: Some bug and typo fixes Richard Fitzgerald
` (2 preceding siblings ...)
2026-05-21 12:25 ` [PATCH 3/3] ASoC: cs-amp-lib: Fix typo in error message: write -> read Richard Fitzgerald
@ 2026-05-21 14:13 ` Mark Brown
3 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2026-05-21 14:13 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches
On Thu, 21 May 2026 13:25:08 +0100, Richard Fitzgerald wrote:
> ASoC: cs-amp-lib: Some bug and typo fixes
>
> This series fixes bugs and a typo in cs-amp-lib.
>
> Richard Fitzgerald (3):
> ASoC: cs-amp-lib: Fix wrong sizeof() in
> _cs_amp_set_efi_calibration_data()
> ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup()
> ASoC: cs-amp-lib: Fix typo in error message: write -> read
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.1
Thanks!
[1/3] ASoC: cs-amp-lib: Fix wrong sizeof() in _cs_amp_set_efi_calibration_data()
https://git.kernel.org/broonie/sound/c/67a52d3ebb5a
[2/3] ASoC: cs-amp-lib: Fix missing dput() after debugfs_lookup()
https://git.kernel.org/broonie/sound/c/ba28a07a9a0b
[3/3] ASoC: cs-amp-lib: Fix typo in error message: write -> read
https://git.kernel.org/broonie/sound/c/a68525268685
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] 5+ messages in thread