Commit f77d443c authored by Subhransu S. Prusty's avatar Subhransu S. Prusty Committed by Mark Brown

ASoC: Intel: Skylake: Fix to free resources for dsp_init failure

unmap mmio and free memory resources if dsp_init fails.
Signed-off-by: default avatarSubhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-By: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3b3011ad
...@@ -277,8 +277,10 @@ int skl_init_dsp(struct skl *skl) ...@@ -277,8 +277,10 @@ int skl_init_dsp(struct skl *skl)
} }
ops = skl_get_dsp_ops(skl->pci->device); ops = skl_get_dsp_ops(skl->pci->device);
if (!ops) if (!ops) {
return -EIO; goto unmap_mmio;
ret = -EIO;
}
loader_ops = ops->loader_ops(); loader_ops = ops->loader_ops();
ret = ops->init(bus->dev, mmio_base, irq, ret = ops->init(bus->dev, mmio_base, irq,
...@@ -286,25 +288,35 @@ int skl_init_dsp(struct skl *skl) ...@@ -286,25 +288,35 @@ int skl_init_dsp(struct skl *skl)
&skl->skl_sst); &skl->skl_sst);
if (ret < 0) if (ret < 0)
return ret; goto unmap_mmio;
skl->skl_sst->dsp_ops = ops; skl->skl_sst->dsp_ops = ops;
cores = &skl->skl_sst->cores; cores = &skl->skl_sst->cores;
cores->count = ops->num_cores; cores->count = ops->num_cores;
cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL);
if (!cores->state) if (!cores->state) {
return -ENOMEM; ret = -ENOMEM;
goto unmap_mmio;
}
cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count), cores->usage_count = kcalloc(cores->count, sizeof(*cores->usage_count),
GFP_KERNEL); GFP_KERNEL);
if (!cores->usage_count) { if (!cores->usage_count) {
kfree(cores->state); ret = -ENOMEM;
return -ENOMEM; goto free_core_state;
} }
dev_dbg(bus->dev, "dsp registration status=%d\n", ret); dev_dbg(bus->dev, "dsp registration status=%d\n", ret);
return 0;
free_core_state:
kfree(cores->state);
unmap_mmio:
iounmap(mmio_base);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment