Skip to content

Commit b0035df

Browse files
Shenghao-Dingtiwai
authored andcommitted
ALSA: hda/tas2781: Fix a potential race condition that causes a NULL pointer in case no efi.get_variable exsits
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: 4fe2385 ("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> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 71d2893 commit b0035df

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

sound/hda/codecs/side-codecs/tas2781_hda.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ int tas2781_save_calibration(struct tas2781_hda *hda)
193193
efi_status_t status;
194194
int i;
195195

196+
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
197+
dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
198+
return -EINVAL;
199+
}
200+
196201
if (hda->catlog_id < LENOVO)
197202
efi_guid = tasdev_fct_efi_guid[hda->catlog_id];
198203

sound/hda/codecs/side-codecs/tas2781_hda_i2c.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ static int tas2563_save_calibration(struct tas2781_hda *h)
315315
unsigned int attr;
316316
int ret, i, j, k;
317317

318+
if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) {
319+
dev_err(p->dev, "%s: NO EFI FOUND!\n", __func__);
320+
return -EINVAL;
321+
}
322+
318323
cd->cali_dat_sz_per_dev = TAS2563_CAL_DATA_SIZE * TASDEV_CALIB_N;
319324

320325
/* extra byte for each device is the device number */

0 commit comments

Comments
 (0)