diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 333220f0f8afc0..8d9d3722570122 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -109,12 +109,16 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, codec->vendor_id & 0xffff); if (!codec->chip_name) { err = -ENOMEM; - goto error; + goto error_chip; } return 0; + error_chip: + kfree(codec->vendor_name); error: + pm_runtime_put_noidle(&codec->dev); + pm_runtime_set_suspended(&codec->dev); put_device(&codec->dev); return err; } @@ -127,6 +131,8 @@ EXPORT_SYMBOL_GPL(snd_hdac_device_init); void snd_hdac_device_exit(struct hdac_device *codec) { pm_runtime_put_noidle(&codec->dev); + /* keep balance of runtime PM child_count in parent device */ + pm_runtime_set_suspended(&codec->dev); snd_hdac_bus_remove_device(codec->bus, codec); kfree(codec->vendor_name); kfree(codec->chip_name); diff --git a/sound/soc/sof/intel/hda-codec.c b/sound/soc/sof/intel/hda-codec.c index 2c5c451fa19d77..1685c143e0a94d 100644 --- a/sound/soc/sof/intel/hda-codec.c +++ b/sound/soc/sof/intel/hda-codec.c @@ -151,7 +151,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, if (!hdev->bus->audio_component) { dev_dbg(sdev->dev, "iDisp hw present but no driver\n"); - return -ENOENT; + goto error; } hda_priv->need_display_power = true; } @@ -174,7 +174,7 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, * other return codes without modification */ if (ret == 0) - ret = -ENOENT; + goto error; } return ret; @@ -187,6 +187,10 @@ static int hda_codec_probe(struct snd_sof_dev *sdev, int address, return ret; #endif + +error: + snd_hdac_ext_bus_device_exit(hdev); + return -ENOENT; } /* Codec initialization */