[lkml]   [2017]   [Sep]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe
When hda_codec_driver_probe meet error and return failure, we need
to free resource with, or we will get resource leak.

Signed-off-by: Wang YanQing <>
Changes v1-v2:
1: Fix calling after module_put, reported by Takashi Iwai.

Hi! Takashi Iwai
Because the only one calling site of is in
hda_codec_driver_remove, and if hda_codec_driver_probe return
failure, we will no chance to call the hda_codec_driver_remove,
so I think we don't need to care below case:
"Or, for safety, we may put an internal flag to indicate that the codec
free got already called, and check it at before calling, too."


sound/pci/hda/hda_bind.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index 6efadbf..d361bb7 100644
--- 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 device *dev)
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 device *dev)
return 0;

+ if (codec->
+ codec->;
+ error_module_put:

 \ /
  Last update: 2017-09-04 17:20    [W:0.041 / U:1.488 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site