Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2197024iof; Tue, 7 Jun 2022 22:55:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvFb74xs+8LSgHbw9C4vLO6eRlb/2MSQt+6Q1/ACiNZ8L6CsOGEsX+RKTz3Y99pH4OmUu4 X-Received: by 2002:a63:2b02:0:b0:3fb:fe88:8a8f with SMTP id r2-20020a632b02000000b003fbfe888a8fmr28295718pgr.247.1654667734921; Tue, 07 Jun 2022 22:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667734; cv=none; d=google.com; s=arc-20160816; b=c5dJ8X42SWrG73YRmewRL62N6i7tc+/py0VyItvz6etF8rqindP+778vStUbAOcg+I Lna6OGz8cdVgD9eugP2Z6Vyi8yYSXIxFadysCbb+oVdK1io5KoURe/AyMq6YX3fQUOqn EzZMzgKJRq0G73rdXD55kIkR/H4cHovBe1UGoeebaUeD3RQn6X2tr5qg1Xt4aH/0kj/w 7RGm+PBHK34/dmICSqFkRHzjik0knVcZeQGT2EfN0LMORTTwsS6qcZlDsYFu6UOxtdju dLCdyfmRW98csCpeV7LPE+eGu06W54smD3jqgsUtuvcMYKNX+ifIrG7yk6NznC4hcVjO MSYw== 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=YUlliHsZQgnZ4mZTo09kXUL1jj37CEGOu541OUzjQtE=; b=lIHW9Nae/sK6RWoxjrkzYERkft0uy0eNbt2UaQtJobrKfJ4/Fo53RS6LQiLGKW0ity b1evk8iXwtjLAgjKAeyqCSbh52g+ZdXFYe+GF/HAhY1gJZRzKXz4R1X6s7AUrVE0e2sx yPmB7G98vgF0/OrCL7EBZo8iEEr2DCAkzCGK5WIRhIClUyRasFKnrGOr1cgdW4kHmxnu iF36U61VYAFPzOe4YQODRixB+Q/w1M0R8zNuRlntxlnFlofATU5SDqbqsxPjV8QbwkjN iUnf14wdHmulVHZ6zl5lGGMiDHapU9yPNYcfxTdv0gKlM61okW82f8Q9/VuaiE1QSsAP RoVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="S/CqYdNs"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id n6-20020a170903110600b00158b603b0aesi33345260plh.589.2022.06.07.22.55.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:55:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="S/CqYdNs"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 BF62013D76; Tue, 7 Jun 2022 22:21:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443466AbiFHA6D (ORCPT + 99 others); Tue, 7 Jun 2022 20:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381724AbiFGVsX (ORCPT ); Tue, 7 Jun 2022 17:48:23 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2197123A026; Tue, 7 Jun 2022 12:08:19 -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 ams.source.kernel.org (Postfix) with ESMTPS id 6C017B823B0; Tue, 7 Jun 2022 19:08:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1EACC341C6; Tue, 7 Jun 2022 19:08:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628896; bh=Oa09tsOvQ9Bl2U03X5wl5mPwZC6XEVRvJHjy6u3ZsTY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/CqYdNsLBvzPKBadwtLDQOPZX7jm23PH+6IwIxWuy1A5pf/z160zgMa03x6BBStX Yl8xn2D63OCMKNCfMQ2l40qZ0meGYT9SC3hJWcK/+HdULD4sp30IZPTmCyJWxPwouo P88DWE+KmTOk5DJDuw3hKo8y6pAMbX7u1rEqguEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaoqian Lin , Daniel Lezcano , Sasha Levin Subject: [PATCH 5.18 494/879] thermal/drivers/imx_sc_thermal: Fix refcount leak in imx_sc_thermal_probe Date: Tue, 7 Jun 2022 19:00:12 +0200 Message-Id: <20220607165017.210265359@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 09700c504d8e63faffd2a2235074e8c5d130cb8f ] of_find_node_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when done. Add missing of_node_put() to avoid refcount leak. Fixes: e20db70dba1c ("thermal: imx_sc: add i.MX system controller thermal support") Signed-off-by: Miaoqian Lin Link: https://lore.kernel.org/r/20220517055121.18092-1-linmq006@gmail.com Signed-off-by: Daniel Lezcano Signed-off-by: Sasha Levin --- drivers/thermal/imx_sc_thermal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/imx_sc_thermal.c b/drivers/thermal/imx_sc_thermal.c index 8d76dbfde6a9..331a241eb0ef 100644 --- a/drivers/thermal/imx_sc_thermal.c +++ b/drivers/thermal/imx_sc_thermal.c @@ -94,8 +94,8 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) sensor = devm_kzalloc(&pdev->dev, sizeof(*sensor), GFP_KERNEL); if (!sensor) { of_node_put(child); - of_node_put(sensor_np); - return -ENOMEM; + ret = -ENOMEM; + goto put_node; } ret = thermal_zone_of_get_sensor_id(child, @@ -124,7 +124,9 @@ static int imx_sc_thermal_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "failed to add hwmon sysfs attributes\n"); } +put_node: of_node_put(sensor_np); + of_node_put(np); return ret; } -- 2.35.1