From patchwork Mon Oct 24 11:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9747 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp548947wru; Mon, 24 Oct 2022 09:42:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78fmBhBVKD7RzP8sBsKK9Q/p/x8ykeI8oW4+sfOUleNTfb1PgKzOW/JxND1eB1aUzV/EgY X-Received: by 2002:a65:6ccd:0:b0:439:2033:6ee with SMTP id g13-20020a656ccd000000b00439203306eemr29554198pgw.271.1666629774965; Mon, 24 Oct 2022 09:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629774; cv=none; d=google.com; s=arc-20160816; b=KDHaPuSfnVkN+wuSSFRv4pXVO5UjxxxnL1R9BehCm0T+BlU+OnV1x8JuHSOZHzYnbN uMArtCsYB+C9jxEu1hxxQWCfr7PbPDphPmFqs0JVC7wocr6TiXFbuYKpSGefRmHNNHKN 0asIfv6xbE3fZLQDorLYNN9VxzLG24kNavQ6GDFtUh5dZQ9aclzcx129JhWSa4YY69Xt jEHTrs3LilNZD2LcshLH76apxBjOiSHgEbMop0UqGGLHh3WE0Dpsu9JT5++oD4uN93e+ wDUpxO4s9bmT4vqs2QU6YwF2Lp6w8pwJnrOfSvs+tRvoOG1NQ6X6XbS+tl4G1cyqVaVx tNwQ== 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=2vl5V9pT1vFdnllBfDn9kAQ6fSg/ASdf0DY5/XYic3c=; b=wBgH8wdnGniXH9Dq4XILRIGo6PCvvQfiyh42ko5n2YQjTCtkEx/HON//mtjCRLgpEa lEMAuZWU1rSqVCndE0BrbGlq8jDFJVb4R22YLyZRL1LK30tW/lLyf9w8Czz7n+kKqvTs 8nhFgCGuW/Iu9F9mKv0mZxCALLFh3kNW0+YqwnP8OlNh8IUDfdmP3XCd7oJPju4/mpej Tarni/1D1MYprrdpIqV1P9X4VtyYpUHp6YBi/lIKXiJzSTyBzwrBpelNDb5FFClTh9ER GRXQFavrIAa6NmTeb7oNOJOP+UXYI0rrYIhIqrV1yb7M5Du5ZWIGcuGgkRUSuHPhDCVP peNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e3bBgxAU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y193-20020a638aca000000b0046edf6af557si8103497pgd.839.2022.10.24.09.42.41; Mon, 24 Oct 2022 09:42:54 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=e3bBgxAU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234639AbiJXQmQ (ORCPT + 99 others); Mon, 24 Oct 2022 12:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234491AbiJXQlW (ORCPT ); Mon, 24 Oct 2022 12:41:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E753FA18F; Mon, 24 Oct 2022 08:28:42 -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 E9A62B8133B; Mon, 24 Oct 2022 12:09:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C8EFC433C1; Mon, 24 Oct 2022 12:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613366; bh=yid7h1IcFvUUz+yr0Ju4t5/VBxBQceYRkM+JldNnPCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e3bBgxAUP+M+Jd8blBglFIF8JBg6NMnMWQjDrNwdFZpKb9qfJ2tkP/oe/TXyxChU8 VQIvlp4sUk0lH2L1ws/XoqhXUMYlXrjXCk0TWxew6jxdtsDH58V2RKmYCwc+VAEYCO z1pnzF+sdirgGCpmszyuSLMSFdILTkRj20PbvnbM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liang He , Krzysztof Kozlowski , Sasha Levin Subject: [PATCH 5.4 109/255] memory: of: Fix refcount leak bug in of_get_ddr_timings() Date: Mon, 24 Oct 2022 13:30:19 +0200 Message-Id: <20221024113006.100020154@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747587983151844780?= X-GMAIL-MSGID: =?utf-8?q?1747587983151844780?= From: Liang He [ Upstream commit 05215fb32010d4afb68fbdbb4d237df6e2d4567b ] We should add the of_node_put() when breaking out of for_each_child_of_node() as it will automatically increase and decrease the refcount. Fixes: e6b42eb6a66c ("memory: emif: add device tree support to emif driver") Signed-off-by: Liang He Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20220719085640.1210583-1-windhl@126.com Signed-off-by: Sasha Levin --- drivers/memory/of_memory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/memory/of_memory.c b/drivers/memory/of_memory.c index 46539b27a3fb..835754304a7f 100644 --- a/drivers/memory/of_memory.c +++ b/drivers/memory/of_memory.c @@ -132,6 +132,7 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr, for_each_child_of_node(np_ddr, np_tim) { if (of_device_is_compatible(np_tim, tim_compat)) { if (of_do_get_timings(np_tim, &timings[i])) { + of_node_put(np_tim); devm_kfree(dev, timings); goto default_timings; }