Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2151250iof; Tue, 7 Jun 2022 21:28:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIfoar9DbyDZgVN7mBYLAsLztCoI2nDzkz/L8cuw+rk227MOSQRmTmlpoKggUYv1A8gHVM X-Received: by 2002:a17:902:bb90:b0:156:2c05:b34f with SMTP id m16-20020a170902bb9000b001562c05b34fmr32783997pls.53.1654662491757; Tue, 07 Jun 2022 21:28:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662491; cv=none; d=google.com; s=arc-20160816; b=XAHGPc211u516+t6zKPpq5Kfxgc1NdvrDAIRMudHiRcAoKADyTdCrHW2BAQwB2VXiC 1iWo4KYSdu3sGcMnXaQjngAzzl0fQbS5y4Zzq7SeLJdR8HAu4/nSk945O/yHd4c0S9l0 9wBoYFLTwmRjrczOG2L1jhatdz/x322i7DsvD+NUCHioKmVPq/TDmWCLrAZ64lqMN7Tv +IkK7hfnwW6UNoKgHVewV+UTrj4vqr56OYtvADCnrgbLOqPoXpHpA2bzhn4gDHXw1csh dtn4fl0+LUZgZKyOt5JU2kCTa1xE2BQPj958k75ZMVpSVA8hI3GKWGDdQWWt9CEWXOad so6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VU0RT8K+BvCDOJgNAEzLlRKD3fjPbszIrLcFIU2gVlU=; b=xPP3USsF13hkVBVPkCnEi0kKhJoYcRl2n583emxK7UddhE8BHBjBaovSZWVImftTcf C4n2sNOzXd0Mns+6QMUKpzoCCurRj2QWbdieA2NBFRklJOXm2nw6U/M+S8ULm5JcNH+u Np4eShI8+S3gg5XY7aHWAKH3JOax8hSZJLxDYcOiaj+RgFPD0N1eYDkI7Kd+GY2guZG0 w0XeQzKY952/s7mjHcO4ifxriLRjMSX2kcaSIlod55QhWhZ4YYCkeo+DyzwzluxUJ1YM xZrvQrLwrFTJ9WI5L1ebaRL2L2NMM3QT8jBFUoZyzetgP3fvvVUpYSX0BO0HvOxC5Hjh YVzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k3M+Vsai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s16-20020a63ff50000000b003db2ab645d5si26467275pgk.308.2022.06.07.21.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:28:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k3M+Vsai; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C9C9D2D53A3; Tue, 7 Jun 2022 20:57:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347636AbiFGRnP (ORCPT + 99 others); Tue, 7 Jun 2022 13:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347866AbiFGRbU (ORCPT ); Tue, 7 Jun 2022 13:31:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 012E410A63F; Tue, 7 Jun 2022 10:28:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 92B1A60906; Tue, 7 Jun 2022 17:28:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A18F5C385A5; Tue, 7 Jun 2022 17:28:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622917; bh=b9T2ytWkws7EL7G3oLxeMYXBSBUH+aLsHZbV06loISc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k3M+Vsai+sZefGe8rxImIalKZltYxanheDUAEIK4KW9H+ti76lJD4LJ66Atv8HM6F 9G8gaRPWfit5zAGfPPfsydx5yz69v0HwdP8mGU/q/OCCBEeWV5fmNbfP1S7fvefmj8 OTXFQQ6lZjE3B4tmXXvX+LboRqNFpCh05Il+UL7Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Fabio Estevam , Mark Brown , Sasha Levin Subject: [PATCH 5.10 202/452] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe Date: Tue, 7 Jun 2022 19:00:59 +0200 Message-Id: <20220607164914.583496888@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miaoqian Lin [ Upstream commit 41cd312dfe980af869c3503b4d38e62ed20dd3b7 ] of_find_i2c_device_by_node() takes a reference, In error paths, we should call put_device() to drop the reference to aviod refount leak. Fixes: 81e8e4926167 ("ASoC: fsl: add sgtl5000 clock support for imx-sgtl5000") Signed-off-by: Miaoqian Lin Reviewed-by: Fabio Estevam Link: https://lore.kernel.org/r/20220511065803.3957-1-linmq006@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/fsl/imx-sgtl5000.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index f45cb4bbb6c4..5997bb5acb73 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -120,19 +120,19 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); if (!data) { ret = -ENOMEM; - goto fail; + goto put_device; } comp = devm_kzalloc(&pdev->dev, 3 * sizeof(*comp), GFP_KERNEL); if (!comp) { ret = -ENOMEM; - goto fail; + goto put_device; } data->codec_clk = clk_get(&codec_dev->dev, NULL); if (IS_ERR(data->codec_clk)) { ret = PTR_ERR(data->codec_clk); - goto fail; + goto put_device; } data->clk_frequency = clk_get_rate(data->codec_clk); @@ -158,10 +158,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) data->card.dev = &pdev->dev; ret = snd_soc_of_parse_card_name(&data->card, "model"); if (ret) - goto fail; + goto put_device; ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); if (ret) - goto fail; + goto put_device; data->card.num_links = 1; data->card.owner = THIS_MODULE; data->card.dai_link = &data->dai; @@ -176,7 +176,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) if (ret != -EPROBE_DEFER) dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto fail; + goto put_device; } of_node_put(ssi_np); @@ -184,6 +184,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) return 0; +put_device: + put_device(&codec_dev->dev); fail: if (data && !IS_ERR(data->codec_clk)) clk_put(data->codec_clk); -- 2.35.1