From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23AE08820 for ; Fri, 10 Mar 2023 14:55:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 647F5C433D2; Fri, 10 Mar 2023 14:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678460102; bh=2YANKMYbByIzXzo2ZLoJjDiFPk2iWqDx2CA27JI5vUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nx0IXcSR0qPrQRqrHlRlXRT2PWW3bj7LyN/dBCSb0142wWF4uapSsx/3FAmPeS8rL 7DXaKvVa5lVdHfyGo+kUV0h/+p6utLYwgc8UhhzcIZjt7aC53oixu1jocR+S75kHGu XnxCeOLrgUC3Uky51Wu8mRO9UcnRwLlGZvdz6ejs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Miaoqian Lin , Lee Jones , Sasha Levin Subject: [PATCH 5.10 224/529] leds: led-core: Fix refcount leak in of_led_get() Date: Fri, 10 Mar 2023 14:36:07 +0100 Message-Id: <20230310133815.385500279@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133804.978589368@linuxfoundation.org> References: <20230310133804.978589368@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Miaoqian Lin [ Upstream commit da1afe8e6099980fe1e2fd7436dca284af9d3f29 ] class_find_device_by_of_node() calls class_find_device(), it will take the reference, use the put_device() to drop the reference when not need anymore. Fixes: 699a8c7c4bd3 ("leds: Add of_led_get() and led_put()") Signed-off-by: Miaoqian Lin Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20221220121807.1543790-1-linmq006@gmail.com Signed-off-by: Sasha Levin --- drivers/leds/led-class.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index e28a4bb716032..fcb9eee3b6097 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -236,6 +236,7 @@ struct led_classdev *of_led_get(struct device_node *np, int index) led_dev = class_find_device_by_of_node(leds_class, led_node); of_node_put(led_node); + put_device(led_dev); if (!led_dev) return ERR_PTR(-EPROBE_DEFER); -- 2.39.2