Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1726134 > unrolled thread
| Started by | Wang YanQing <udknight@gmail.com> |
|---|---|
| First post | 2017-09-04 17:20 +0200 |
| Last post | 2017-09-04 17:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe Wang YanQing <udknight@gmail.com> - 2017-09-04 17:20 +0200
Re: [PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe Takashi Iwai <tiwai@suse.de> - 2017-09-04 17:40 +0200
| From | Wang YanQing <udknight@gmail.com> |
|---|---|
| Date | 2017-09-04 17:20 +0200 |
| Subject | [PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe |
| Message-ID | <um1kl-77N-7@gated-at.bofh.it> |
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>
---
Changes v1-v2:
1: Fix calling patch_ops.free after module_put, reported by Takashi Iwai.
Hi! Takashi Iwai
Because the only one calling site of patch_ops.free 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
patch_ops.free, too."
Thanks!
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;
error_module:
+ if (codec->patch_ops.free)
+ codec->patch_ops.free(codec);
+ error_module_put:
module_put(owner);
error:
--
1.8.5.6.2.g3d8a54e.dirty
[toc] | [next] | [standalone]
| From | Takashi Iwai <tiwai@suse.de> |
|---|---|
| Date | 2017-09-04 17:40 +0200 |
| Subject | Re: [PATCH v2] ALSA: hda: Fix forget to free resource in error handling code path in hda_codec_driver_probe |
| Message-ID | <um1DI-7e8-15@gated-at.bofh.it> |
| In reply to | #1726134 |
On Mon, 04 Sep 2017 17:17:09 +0200, Wang YanQing wrote: > > 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> > --- > Changes v1-v2: > 1: Fix calling patch_ops.free after module_put, reported by Takashi Iwai. > > Hi! Takashi Iwai > Because the only one calling site of patch_ops.free 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 > patch_ops.free, too." Fair enough, applied now. I found patch_ca0132.c still misses the free at the error path in its probe function, so I'll fix it. thanks, Takashi
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web