mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: opti9xx: Fix memleak in snd_opti9xx_read_check
@ 2020-08-29  8:05 Dinghao Liu
  2020-08-31  9:48 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-08-29  8:05 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Jaroslav Kysela, Takashi Iwai, Gustavo A. R. Silva,
	Arnd Bergmann, alsa-devel, linux-kernel

When request_region() on chip->res_mc_indir fails,
chip->res_mc_base should be freed to prevent memleak.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 sound/isa/opti9xx/opti92x-ad1848.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c
index 881d3b5711d2..06ba18d1737c 100644
--- a/sound/isa/opti9xx/opti92x-ad1848.c
+++ b/sound/isa/opti9xx/opti92x-ad1848.c
@@ -679,8 +679,11 @@ static int snd_opti9xx_read_check(struct snd_opti9xx *chip)
 #else	/* OPTi93X */
 	chip->res_mc_indir = request_region(chip->mc_indir_index, 2,
 					    "OPTi93x MC");
-	if (chip->res_mc_indir == NULL)
+	if (chip->res_mc_indir == NULL) {
+		release_and_free_resource(chip->res_mc_base);
+		chip->res_mc_base = NULL;
 		return -EBUSY;
+	}
 
 	spin_lock_irqsave(&chip->lock, flags);
 	outb(chip->password, chip->mc_base + chip->pwd_reg);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-31  9:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-29  8:05 [PATCH] ALSA: opti9xx: Fix memleak in snd_opti9xx_read_check Dinghao Liu
2020-08-31  9:48 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®