From patchwork Mon Oct 24 11:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 10272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp644965wru; Mon, 24 Oct 2022 13:46:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Zg654U/QLueHpI/NA4UOTudirg4aIP2anQ4tdhOwxLCElv6E4ukYnz2QrLxw5XVwYp2VB X-Received: by 2002:a17:902:a60c:b0:184:fa22:8b3c with SMTP id u12-20020a170902a60c00b00184fa228b3cmr34283994plq.136.1666644391440; Mon, 24 Oct 2022 13:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666644391; cv=none; d=google.com; s=arc-20160816; b=dmoOwi6b0aNftJn/TZlxGqn/hEWIQEXn7R1NbrO5iOrjxjspNhn/IZBDzsN2HF7W+h JhgrvV7pBeskl+A8DV1C9SxWz+nQbUyts+nvZH6Vy7nTGtzwtshyXMEcpYkkpwiOEq+G 1NuTzO1v+7VgPbOZE4U7ulR7lzhQuAHvLj6j5JDymDr+dzgqrETq7mw0n6yzFQ4TRMc3 n/s9R+l4xIlXMlZDmE+3VukIZBLWyZwA9lIQgGfecvcrCyXhXLqEzhBcL2WtMe5EFu+v mdPnPYDTrPopKIrvQgCl2GjU9tDFqSJj2Ge3RfEXA42t8fYFaT3g0D8ckpdHnerpIc8l p+6A== 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=41Y6EdhkH8V7rf9AfmNpUAgoyZcnGmOch8y50OHZNes=; b=py7PdnMSSd6vuONdHBcY41Ty2GG0Y5QeCkuNdX1h3mycL4kY9UV+fb2a4qSieW7RrD 5Sd0EtD/2RV5zU6RTdGgeNQzxEPU27OEPIo8OWGTkks3xkcc1YT9X7h6ZDrvl0+DIvNx /tDfn8g2C0VEmkVPAH/XF1YcYDAau3kvZnCfpNhKnUDRxJLXxI3w+HE8326GUMJmmCQE nzd2M6r0TyskCV95/TUD5S9xMzkybGOWbE+jjzS5tqDiZiNDKS7yT6+iLxb2ZkiO8IAk yWv6icx41Zek0YMkBHcWR2tQQ5G8OHVChVB0peyEN7NXl06KesCig5aeJ2BAXcc/v771 ZXVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="JT/2k+uH"; 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 k9-20020a635a49000000b0043a067266cdsi577555pgm.40.2022.10.24.13.46.18; Mon, 24 Oct 2022 13:46:31 -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="JT/2k+uH"; 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 S235059AbiJXUpp (ORCPT + 99 others); Mon, 24 Oct 2022 16:45:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235191AbiJXUoO (ORCPT ); Mon, 24 Oct 2022 16:44:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F17B129091; Mon, 24 Oct 2022 11:52:22 -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 D48F4B81964; Mon, 24 Oct 2022 12:43:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36509C433C1; Mon, 24 Oct 2022 12:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615426; bh=nggt5QNHZ4QL3rbqvTQdzEH1qGPeqU7CytS2iNQBeXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JT/2k+uHNDv31HA6J5+huVIRbxt42Ccr1KSdZ3Ei4mZlV5qiigcGPkcOSnwkOdaK/ ZoRIu657E40kegzm+9/RgRDXqI2WAU7QDs2ZmycbmdpFXiHIgwW/HGNxzfLJAQB9nJ s7rkPSLdORPJ9ZlxElSl+2SIz7O9W9w1BCNkogvw= 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.15 247/530] memory: of: Fix refcount leak bug in of_get_ddr_timings() Date: Mon, 24 Oct 2022 13:29:51 +0200 Message-Id: <20221024113056.292416714@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747603309802000746?= X-GMAIL-MSGID: =?utf-8?q?1747603309802000746?= 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 d9f5437d3bce..d0a80aefdea8 100644 --- a/drivers/memory/of_memory.c +++ b/drivers/memory/of_memory.c @@ -134,6 +134,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; }