ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_drive...
authorWang YanQing <udknight@gmail.com>
Mon, 4 Sep 2017 15:17:09 +0000 (23:17 +0800)
committerTakashi Iwai <tiwai@suse.de>
Mon, 4 Sep 2017 15:33:53 +0000 (17:33 +0200)
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

index 6efadbfb3fe3511b4726541cdd9ebd4aae6cd65d..d361bb77ca00d1979a572d7a95d13e8a0563b34f 100644 (file)
@@ -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;
 
  error_module:
+       if (codec->patch_ops.free)
+               codec->patch_ops.free(codec);
+ error_module_put:
        module_put(owner);
 
  error: