Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1089796ybt; Wed, 1 Jul 2020 18:38:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDK1L7+evHTCpRMZApzdj/5O+ZczHFlDJgbj2/2fLRva5X/eCkEDhTW6EHBLlYwBsUeIk3 X-Received: by 2002:a50:f058:: with SMTP id u24mr32282700edl.351.1593653932484; Wed, 01 Jul 2020 18:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653932; cv=none; d=google.com; s=arc-20160816; b=aw0b4P7r4Wi+AyK9jcw9C6tbilBfNzJqeC0W0u2JX0L+1Ei83VNK7yD1V7+KhXyTBG wN13E+5mjd4Tb9xVjuQoCQJtv5iAHS/K4DPEsJ3Nttq8xvDRJIDDCyIgci6Gb0E6mRAI y9Pj3TmzSboXLKokMVGAazbHxO/Nl+lj6AQSecj/nIbJe9DVxPhZMDv8WAEfCg75yi4T nd5uDf+fX5ugsPLHJEXtvXiOIK/5ga/H813l0ojA5g16LOj2YL3OYnZ1dKFIyo6yUBWT y0Vxa4//TUQUFrXLhHz24XadflPxy483OQrUM4sivuzFN5uPN6p8t5sJKR+u3/AsGsEs tPyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5MJOxau/evhNFMoPZQy/RoNqOkEOLQvb5WknUYLlZkw=; b=tAB1lAuo4mvmzzgRnWZRylXrSea9Oy5SEwI4pNMQ7GXDUu9XhjY9VGWStv3pr0zk/9 yE/5zF/czTGxqeS62Zrkyv4I0DFp6i7WWnGDE+BtwZVJ83JnZ1DbJzo/XFZfGJV/+0vE /KJAhi33Cce7oMUIgDT4e4aAU3OaaYPfl/CLtnB7/aaN3oA7zwhVO4Wl/kwfFUIHHz3C vxEjMFGYU6ZulzANwRolhZ4k0ydYDYJaegphQ0Gohom9rVUPSsMtitSQR7wxR9VMUoqm GDgTmOH3/sLRc8jG9L185tzz0hW7sJwilnx3IQblri19MHqCU7ei5W3Tiy2vxRpDs0kD 7u8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JD4+9+vQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si4718346ejc.314.2020.07.01.18.38.29; Wed, 01 Jul 2020 18:38:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JD4+9+vQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728260AbgGBBgX (ORCPT + 99 others); Wed, 1 Jul 2020 21:36:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:53700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728248AbgGBBXP (ORCPT ); Wed, 1 Jul 2020 21:23:15 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 06BCD20885; Thu, 2 Jul 2020 01:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593652995; bh=rAToyATJmJzHZQyIyJDmhYm9QwhloqEv1gMsff5kCjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JD4+9+vQiP8pNbS3MptY6bz4I0i2X9/nfIPivDcP72sMqCaYIpzkGp00fUF3yCjta E5HX5XgDvuQyIIjfAFVINkP4Rf3vqbp49q5SOSLIrJjRKPe1z9WvDPLKcUdqNJF78o xmYiW/+20W6yiXPYyTza7E94f1TOTTRiI1vNvr0k= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Daniel Baluta , Kai Vehmanen , Rander Wang , Guennadi Liakhovetski , Bard Liao , Mark Brown , Sasha Levin , alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.7 16/53] ASoC: hdac_hda: fix memleak with regmap not freed on remove Date: Wed, 1 Jul 2020 21:21:25 -0400 Message-Id: <20200702012202.2700645-16-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart [ Upstream commit a94eaccefea1186947c5c5451fcae2245dd7e714 ] kmemleak throws error reports on module load/unload tests, add snd_hdac_regmap_exit() in .remove(). While we are at it, also fix the error handling flow in .probe() to use snd_hdac_regmap_exit() if needed. Signed-off-by: Pierre-Louis Bossart Reviewed-by: Daniel Baluta Reviewed-by: Kai Vehmanen Reviewed-by: Rander Wang Reviewed-by: Guennadi Liakhovetski Reviewed-by: Bard Liao Link: https://lore.kernel.org/r/20200617164144.17859-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/hdac_hda.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index de003acb1951f..473efe9ef998a 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -441,13 +441,13 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) ret = snd_hda_codec_set_name(hcodec, hcodec->preset->name); if (ret < 0) { dev_err(&hdev->dev, "name failed %s\n", hcodec->preset->name); - goto error; + goto error_pm; } ret = snd_hdac_regmap_init(&hcodec->core); if (ret < 0) { dev_err(&hdev->dev, "regmap init failed\n"); - goto error; + goto error_pm; } patch = (hda_codec_patch_t)hcodec->preset->driver_data; @@ -455,7 +455,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) ret = patch(hcodec); if (ret < 0) { dev_err(&hdev->dev, "patch failed %d\n", ret); - goto error; + goto error_regmap; } } else { dev_dbg(&hdev->dev, "no patch file found\n"); @@ -467,7 +467,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) ret = snd_hda_codec_parse_pcms(hcodec); if (ret < 0) { dev_err(&hdev->dev, "unable to map pcms to dai %d\n", ret); - goto error; + goto error_regmap; } /* HDMI controls need to be created in machine drivers */ @@ -476,7 +476,7 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) if (ret < 0) { dev_err(&hdev->dev, "unable to create controls %d\n", ret); - goto error; + goto error_regmap; } } @@ -496,7 +496,9 @@ static int hdac_hda_codec_probe(struct snd_soc_component *component) return 0; -error: +error_regmap: + snd_hdac_regmap_exit(hdev); +error_pm: pm_runtime_put(&hdev->dev); error_no_pm: snd_hdac_ext_bus_link_put(hdev->bus, hlink); @@ -518,6 +520,8 @@ static void hdac_hda_codec_remove(struct snd_soc_component *component) pm_runtime_disable(&hdev->dev); snd_hdac_ext_bus_link_put(hdev->bus, hlink); + + snd_hdac_regmap_exit(hdev); } static const struct snd_soc_dapm_route hdac_hda_dapm_routes[] = { -- 2.25.1