Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2150666iof; Tue, 7 Jun 2022 21:26:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztCKXT/FLFYK9dkDpmyG7oqehqIBIuRLwyQDxUHcMw4g1FWqVH5hbih8DPICpHXt4OQmWE X-Received: by 2002:a17:902:da8e:b0:164:537:d910 with SMTP id j14-20020a170902da8e00b001640537d910mr32145263plx.75.1654662400024; Tue, 07 Jun 2022 21:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662400; cv=none; d=google.com; s=arc-20160816; b=Wi172vrqojkGESVD5WFySPLanQhOHlzZv63H1CJ8lbUaG72vi1XQziOrBNXvGHNlFx 6o08m4Zwj6gIs4mL+pbSMgoYKh1L2sMQBO7ko0GbiKswWvNx/falRnuZLAGDrW55FjMY CS/FmvSAnOpmtfoiSYsK1Fcq7JXK8ZMFuhU153mCRlH8eUrw9iArKokwyA/LFIo8FP8H HiVkpTp2ybZ5br9Wt+HQUUWQC92aDdBSsLyyCdfz7rhazKN0ApQG0QQNsoc+pHAQJ8pB bC3EyKsErr077XCJOE1EYWsQdm8Ye6x0X8SQsGzRXaQVevJQ4P+cug1r12GKkKmDXvm/ rGGA== 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=b5bUKGAYJv03FfUer7GNfbotyKBc3Y6EU7JxCj2wzm0=; b=lBsV0XXHDunZdXOL4WOMhUBF/xif4EsycZo19SwUhlJLQedR9+SEqYcwYt7j+hgwNP OQGMeHypKhkKw91AIc54VAgyLvzGK7IH8H3QZQG0FxdFj2671DsBCwPE7Ffd9YhtvBQX FBXQqYYiAQdXVVhwQriBXSmVBM1JmJ0iJaVrD3uV3AZ9JiE2eO3uUttok7OPqIlDSqHN ZaGCCWIlcvM1jElXa3xnI3wt73i8IJgyXD6XXYc90j7FHvAYE/VKnbliUwjjAsymKhvo OFCjQP3VgRCCMtg7J4tu7jeROCabj38Og2YM+xX7HupssElNS3EJtgUofHnn0jRjhMr8 7wAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D8h9eeSW; 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 fa14-20020a17090af0ce00b001dc681e0241si28990866pjb.27.2022.06.07.21.26.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:26:40 -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=D8h9eeSW; 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 92D87237CA3; Tue, 7 Jun 2022 20:56:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386706AbiFGWtT (ORCPT + 99 others); Tue, 7 Jun 2022 18:49:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381304AbiFGVk0 (ORCPT ); Tue, 7 Jun 2022 17:40:26 -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 2003C232379; Tue, 7 Jun 2022 12:06:35 -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 9F066617DA; Tue, 7 Jun 2022 19:06:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB508C385A2; Tue, 7 Jun 2022 19:06:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628794; bh=wXml3vOeHTe2aPhXSByfJUBg4hzCXWKnW4+DgntOpHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8h9eeSWYvamRFXthoFfu2XooO8kURGeHAXBkXYsSzt4pDAjPicrGsS7YEVj+N3mC lj/C9pgvWQ1ltljXEsRxXpxOKZktD/L/AhYymnNJhQ7twZECADeJDuViVNLdDfVSq5 ZPdiEpU9lHTQ3FrkuVcNkbs1kKcUQemrMlpDtNZI= 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.18 417/879] ASoC: fsl: Fix refcount leak in imx_sgtl5000_probe Date: Tue, 7 Jun 2022 18:58:55 +0200 Message-Id: <20220607165014.964887113@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 8daced42d55e..580a0d963f0e 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; @@ -174,7 +174,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) ret = devm_snd_soc_register_card(&pdev->dev, &data->card); if (ret) { dev_err_probe(&pdev->dev, ret, "snd_soc_register_card failed\n"); - goto fail; + goto put_device; } of_node_put(ssi_np); @@ -182,6 +182,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