* [PATCH 1/2] ALSA: hda/tas2781: Assign total_sz at the end of the function
2026-10-13 9:57 [PATCH 0/2] ALSA: hda/tas2781: Skip invalid TAS2563 UEFI calibration data Gergo Koteles
@ 2026-10-13 9:57 ` Gergo Koteles
2026-10-13 9:57 ` [PATCH 2/2] ALSA: hda/tas2781: Skip invalid TAS2563 UEFI calibration data Gergo Koteles
1 sibling, 0 replies; 3+ messages in thread
From: Gergo Koteles @ 2026-10-13 9:57 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Jaroslav Kysela,
Takashi Iwai, Philipp Oster, Georg Wenzel
Cc: linux-sound, linux-kernel, alsa-devel, Gergo Koteles, stable
In the tas2563_save_calibration() function, cd->total_sz is assigned in
several error paths.
Move the assignment to the end of the function.
Fixes: b6016332b889 ("ALSA: hda/tas2781: clear cali_data.total_sz when calibration read fails")
Cc: <stable@vger.kernel.org> # 6.18
Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index 5e5f46c9fb6b..f1329bb6adcd 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -337,8 +337,8 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
cd->cali_dat_sz_per_dev = TAS2563_CAL_DATA_SIZE * TASDEV_CALIB_N;
/* extra byte for each device is the device number */
- cd->total_sz = (cd->cali_dat_sz_per_dev + 1) * p->ndev;
- data = cd->data = devm_kzalloc(p->dev, cd->total_sz,
+ data = cd->data = devm_kzalloc(p->dev,
+ (cd->cali_dat_sz_per_dev + 1) * p->ndev,
GFP_KERNEL);
if (!data)
return -ENOMEM;
@@ -352,7 +352,6 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
if (ret < 0 || ret >= sizeof(var8) - 1) {
dev_err(p->dev, "%s: Read %s failed\n",
__func__, var8);
- cd->total_sz = 0;
return -EINVAL;
}
/*
@@ -370,7 +369,6 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
dev_warn(p->dev,
"Dev %d: Caldat[%d] read failed %ld\n",
i, j, status);
- cd->total_sz = 0;
return -EINVAL;
}
bedata = cpu_to_be32(*(uint32_t *)&data[offset]);
@@ -379,12 +377,7 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
}
}
- if (cd->total_sz != offset) {
- dev_err(p->dev, "%s: tot_size(%lu) and offset(%u) mismatch\n",
- __func__, cd->total_sz, offset);
- cd->total_sz = 0;
- return -EINVAL;
- }
+ cd->total_sz = offset;
r->r0_reg = TAS2563_CAL_R0;
r->invr0_reg = TAS2563_CAL_INVR0;
--
2.56.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 2/2] ALSA: hda/tas2781: Skip invalid TAS2563 UEFI calibration data
2026-10-13 9:57 [PATCH 0/2] ALSA: hda/tas2781: Skip invalid TAS2563 UEFI calibration data Gergo Koteles
2026-10-13 9:57 ` [PATCH 1/2] ALSA: hda/tas2781: Assign total_sz at the end of the function Gergo Koteles
@ 2026-10-13 9:57 ` Gergo Koteles
1 sibling, 0 replies; 3+ messages in thread
From: Gergo Koteles @ 2026-10-13 9:57 UTC (permalink / raw)
To: Shenghao Ding, Kevin Lu, Baojun Xu, Sen Wang, Jaroslav Kysela,
Takashi Iwai, Philipp Oster, Georg Wenzel
Cc: linux-sound, linux-kernel, alsa-devel, Gergo Koteles, stable
Some Lenovo 14ARB7 laptops do not have proper calibration data.
Skip these zero calibration values and fall back to the calibration data
provided by the DSP firmware.
Tested-by: Georg Wenzel <g.wenzel@gmail.com>
Fixes: c3ca4458cc2f ("ALSA: hda/tas2781: add TAS2563 support for 14ARB7")
Cc: <stable@vger.kernel.org> # 6.18
Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index f1329bb6adcd..53d9c101b421 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -371,6 +371,11 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
i, j, status);
return -EINVAL;
}
+ if (*(uint32_t *)&data[offset] == 0) {
+ dev_warn(p->dev,
+ "Dev %d: Caldat[%d] is zero\n", i, j);
+ return -EINVAL;
+ }
bedata = cpu_to_be32(*(uint32_t *)&data[offset]);
memcpy(&data[offset], &bedata, sizeof(bedata));
offset += TAS2563_CAL_DATA_SIZE;
--
2.56.0
^ permalink raw reply related [flat|nested] 3+ messages in thread