public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits
@ 2025-09-11  7:11 Shenghao Ding
  2025-09-11 16:11 ` Takashi Iwai
  2025-10-02 19:27 ` Gergo Koteles
  0 siblings, 2 replies; 4+ messages in thread
From: Shenghao Ding @ 2025-09-11  7:11 UTC (permalink / raw)
  To: tiwai
  Cc: broonie, andriy.shevchenko, 13564923607, 13916275206, alsa-devel,
	linux-kernel, baojun.xu, Baojun.Xu, Shenghao Ding

A a potential race condition reported by one of my customers that leads to
a NULL pointer dereference, where the call to efi.get_variable should be
guarded with efi_rt_services_supported() to ensure that function exists.

Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib")
Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
---
 sound/hda/codecs/side-codecs/tas2781_hda.c     | 5 +++++
 sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/side-codecs/tas2781_hda.c
index 536940c78f00..96e6d82dc69e 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda.c
@@ -193,6 +193,11 @@ int tas2781_save_calibration(struct tas2781_hda *hda)
 	efi_status_t status;
 	int i;
 
+	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
+		dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
+		return -EINVAL;
+	}
+
 	if (hda->catlog_id < LENOVO)
 		efi_guid = tasdev_fct_efi_guid[hda->catlog_id];
 
diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
index 008dbe1490a7..4dea442d8c30 100644
--- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
+++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
@@ -317,6 +317,11 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
 	unsigned int attr;
 	int ret, i, j, k;
 
+	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
+		dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
+		return -EINVAL;
+	}
+
 	cd->cali_dat_sz_per_dev = TAS2563_CAL_DATA_SIZE * TASDEV_CALIB_N;
 
 	/* extra byte for each device is the device number */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits
  2025-09-11  7:11 [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits Shenghao Ding
@ 2025-09-11 16:11 ` Takashi Iwai
  2025-10-02 19:27 ` Gergo Koteles
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2025-09-11 16:11 UTC (permalink / raw)
  To: Shenghao Ding
  Cc: broonie, andriy.shevchenko, 13564923607, 13916275206, alsa-devel,
	linux-kernel, baojun.xu, Baojun.Xu

On Thu, 11 Sep 2025 09:11:31 +0200,
Shenghao Ding wrote:
> 
> A a potential race condition reported by one of my customers that leads to
> a NULL pointer dereference, where the call to efi.get_variable should be
> guarded with efi_rt_services_supported() to ensure that function exists.
> 
> Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib")
> Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>

Thanks, applied now.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits
  2025-09-11  7:11 [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits Shenghao Ding
  2025-09-11 16:11 ` Takashi Iwai
@ 2025-10-02 19:27 ` Gergo Koteles
  2025-10-03  6:09   ` Greg KH
  1 sibling, 1 reply; 4+ messages in thread
From: Gergo Koteles @ 2025-10-02 19:27 UTC (permalink / raw)
  To: Shenghao Ding, tiwai
  Cc: broonie, andriy.shevchenko, 13564923607, 13916275206, alsa-devel,
	linux-kernel, baojun.xu, Baojun.Xu, stable

Cc: <stable@vger.kernel.org>

On Thu, 2025-09-11 at 15:11 +0800, Shenghao Ding wrote:
> A a potential race condition reported by one of my customers that leads to
> a NULL pointer dereference, where the call to efi.get_variable should be
> guarded with efi_rt_services_supported() to ensure that function exists.
> 
> Fixes: 4fe238513407 ("ALSA: hda/tas2781: Move and unified the calibrated-data getting function for SPI and I2C into the tas2781_hda lib")
> Signed-off-by: Shenghao Ding <shenghao-ding@ti.com>
> ---
>  sound/hda/codecs/side-codecs/tas2781_hda.c     | 5 +++++
>  sound/hda/codecs/side-codecs/tas2781_hda_i2c.c | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/sound/hda/codecs/side-codecs/tas2781_hda.c b/sound/hda/codecs/side-codecs/tas2781_hda.c
> index 536940c78f00..96e6d82dc69e 100644
> --- a/sound/hda/codecs/side-codecs/tas2781_hda.c
> +++ b/sound/hda/codecs/side-codecs/tas2781_hda.c
> @@ -193,6 +193,11 @@ int tas2781_save_calibration(struct tas2781_hda *hda)
>  	efi_status_t status;
>  	int i;
>  
> +	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
> +		dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
> +		return -EINVAL;
> +	}
> +
>  	if (hda->catlog_id < LENOVO)
>  		efi_guid = tasdev_fct_efi_guid[hda->catlog_id];
>  
> diff --git a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> index 008dbe1490a7..4dea442d8c30 100644
> --- a/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> +++ b/sound/hda/codecs/side-codecs/tas2781_hda_i2c.c
> @@ -317,6 +317,11 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
>  	unsigned int attr;
>  	int ret, i, j, k;
>  
> +	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
> +		dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
> +		return -EINVAL;
> +	}
> +
>  	cd->cali_dat_sz_per_dev = TAS2563_CAL_DATA_SIZE * TASDEV_CALIB_N;
>  
>  	/* extra byte for each device is the device number */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits
  2025-10-02 19:27 ` Gergo Koteles
@ 2025-10-03  6:09   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-10-03  6:09 UTC (permalink / raw)
  To: Gergo Koteles
  Cc: Shenghao Ding, tiwai, broonie, andriy.shevchenko, 13564923607,
	13916275206, alsa-devel, linux-kernel, baojun.xu, Baojun.Xu,
	stable

On Thu, Oct 02, 2025 at 09:27:46PM +0200, Gergo Koteles wrote:
> Cc: <stable@vger.kernel.org>

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-03  6:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  7:11 [PATCH v1] ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits Shenghao Ding
2025-09-11 16:11 ` Takashi Iwai
2025-10-02 19:27 ` Gergo Koteles
2025-10-03  6:09   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox