From 284b4c9289766c6294d4c6292aea565f78215b0e Mon Sep 17 00:00:00 2001
From: Wang YanQing <udknight@gmail.com>
Date: Mon, 4 Sep 2017 23:17:09 +0800
Subject: [PATCH] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe
Git-commit: 284b4c9289766c6294d4c6292aea565f78215b0e
Patch-mainline: v4.14-rc1
References: bsc#1052235
When hda_codec_driver_probe meet error and return failure, we need
to free resource with patch_ops.free, or we will get resource leak.
Signed-off-by: Wang YanQing <udknight@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/pci/hda/hda_bind.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -100,7 +100,7 @@ static int hda_codec_driver_probe(struct
if (patch) {
err = patch(codec);
if (err < 0)
- goto error_module;
+ goto error_module_put;
}
err = snd_hda_codec_build_pcms(codec);
@@ -120,6 +120,9 @@ static int hda_codec_driver_probe(struct
return 0;
error_module:
+ if (codec->patch_ops.free)
+ codec->patch_ops.free(codec);
+ error_module_put:
module_put(owner);
error: