Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp14910784rwb; Mon, 28 Nov 2022 06:13:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf6QTrb9rip3XlKfm5HWPcOHSaOz7Vhgm8olcmYuP0VKUk5xBnZiHzEVVQdIcTl6gJsOiG+d X-Received: by 2002:a17:906:2804:b0:78d:e7c0:a2b with SMTP id r4-20020a170906280400b0078de7c00a2bmr44558587ejc.273.1669644838897; Mon, 28 Nov 2022 06:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669644838; cv=none; d=google.com; s=arc-20160816; b=mOPgKtvO/5ov3DubLdRNmFc5/KCVuOD2Osz/Fu2Ti8TWO3QkUDnLomQq+q734jsv2F avsX2uK8sz90155nhoel12pTJyaQjSifcq2gWaAQ+5rNxbpc5BG13Poa0JrhMoaE99xn E0mWt0rowqes/s0R/LLAOVud0zE3zMW0o8TTEtkkivNj6KYd21hbVKxhD5+NRhrmoGc0 9q1uPo4ibiUE8bnuOQjQGrf2u02tKvUCdFZlSc6bQmU3ZYlDe+UbDhxCYjuMY7GVoQNq bmFo02zyFK2Okj7w5HBdl3YfdgFsCM5ZJTNPJV64sj8S4lslrOxLvK71+j9VlB9f7vW6 nIJg== 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 :message-id:date:subject:cc:to:from; bh=wrE8/hU9HLCBljgwMXFcZjLtHXlKGprBbpf0iOQzyb4=; b=WCZ6wdkvsMtR9FdON78auqKY+DR5XIjVik2hX6OMhs6a2316GntN5OmvMn96uUIEXN ylYG4ANKK6qjVpwE4PbYThugkd+syDQtP+JQjExs8JR/1wMS4YAs/DTg9CIVqWN3VkPX eig8w9NDfGGKOh0S1TSsbcUD/FyI8/AxmN3Tb+WuX3yZIAVwTcZBjq/v5WGIo+beSQ+c crmLMu6xHS8eC2vX1FsEqk882Aqsv/lJNbqoCPCK+XJaSk5S6XM2bZuEKVgkYrwxE1Ia TNl7wYHTBEL/qbeaZ8gKT/4UMaKiiUuI3vFWXe7kMbwhdbutmsmAVJsRFK3CesT8qkas OM+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s4-20020a056402520400b00443e3fe60a0si10228997edd.622.2022.11.28.06.13.37; Mon, 28 Nov 2022 06:13:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232400AbiK1OJM (ORCPT + 84 others); Mon, 28 Nov 2022 09:09:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232385AbiK1OIs (ORCPT ); Mon, 28 Nov 2022 09:08:48 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7632188C; Mon, 28 Nov 2022 06:07:54 -0800 (PST) Received: from kwepemi500014.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NLRyv3vHdzqSk3; Mon, 28 Nov 2022 22:03:51 +0800 (CST) Received: from localhost.localdomain (10.175.112.70) by kwepemi500014.china.huawei.com (7.221.188.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 28 Nov 2022 22:07:51 +0800 From: Qiheng Lin To: CC: , , Qiheng Lin Subject: [PATCH] power: supply: Fix refcount leak in rk817_charger_probe Date: Mon, 28 Nov 2022 22:27:40 +0800 Message-ID: <20221128142740.1414-1-linqiheng@huawei.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500014.china.huawei.com (7.221.188.232) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak. Fixes: 11cb8da0189b ("power: supply: Add charger driver for Rockchip RK817") Signed-off-by: Qiheng Lin --- drivers/power/supply/rk817_charger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/power/supply/rk817_charger.c b/drivers/power/supply/rk817_charger.c index 635f051b0821..d25a81d79fac 100644 --- a/drivers/power/supply/rk817_charger.c +++ b/drivers/power/supply/rk817_charger.c @@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev) return -ENODEV; charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL); - if (!charger) + if (!charger) { + of_node_put(node); return -ENOMEM; + } charger->rk808 = rk808; -- 2.32.0