Commit 45459d16 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: x86: Handle the error from hdmi_audio_probe() properly

The error from hdmi_audio_probe() wasn't handled properly, and it may
leave some resources leaked or mapped.  Fix it and also clean up the
error paths.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 79dda75a
...@@ -422,16 +422,14 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) ...@@ -422,16 +422,14 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
NULL); NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&hlpe_pdev->dev, "request_irq failed\n"); dev_err(&hlpe_pdev->dev, "request_irq failed\n");
iounmap(mmio_start); goto error_irq;
return -ENODEV;
} }
/* alloc and save context */ /* alloc and save context */
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (ctx == NULL) { if (ctx == NULL) {
free_irq(irq, NULL); ret = -ENOMEM;
iounmap(mmio_start); goto error_ctx;
return -ENOMEM;
} }
ctx->irq = irq; ctx->irq = irq;
...@@ -454,15 +452,16 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) ...@@ -454,15 +452,16 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
if (pdata == NULL) { if (pdata == NULL) {
dev_err(&hlpe_pdev->dev, "%s: quit: pdata not allocated by i915!!\n", __func__); dev_err(&hlpe_pdev->dev, "%s: quit: pdata not allocated by i915!!\n", __func__);
kfree(ctx); ret = -ENOMEM;
free_irq(irq, NULL); goto error_probe;
iounmap(mmio_start);
return -ENOMEM;
} }
platform_set_drvdata(pdev, ctx); platform_set_drvdata(pdev, ctx);
ret = hdmi_audio_probe(pdev, &ctx->had); ret = hdmi_audio_probe(pdev, &ctx->had);
if (ret < 0)
goto error_probe;
dev_dbg(&hlpe_pdev->dev, "hdmi lpe audio: setting pin eld notify callback\n"); dev_dbg(&hlpe_pdev->dev, "hdmi lpe audio: setting pin eld notify callback\n");
/* The Audio driver is loading now and we need to notify /* The Audio driver is loading now and we need to notify
...@@ -483,6 +482,14 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev) ...@@ -483,6 +482,14 @@ static int hdmi_lpe_audio_probe(struct platform_device *pdev)
spin_unlock_irqrestore(&pdata->lpe_audio_slock, flag_irq); spin_unlock_irqrestore(&pdata->lpe_audio_slock, flag_irq);
return ret; return ret;
error_probe:
kfree(ctx);
error_ctx:
free_irq(irq, NULL);
error_irq:
iounmap(mmio_start);
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