Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1950277lqm; Fri, 3 May 2024 10:52:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU00GGfp1REG1gYtBqzhrylgKOdF2FkUlbRtO/DHVmJqJzZn008vVrQDplp1WLdHZIoOxYlZyC36p0DttuWhCKjwUdxTn+MYA3/9Nht9w== X-Google-Smtp-Source: AGHT+IGjWECa7By8QXKIn14M03YwR7L5ZikpBF93f6PZcF1q7PAd/Z6gVAF47qCiYj5mfh3jEIBK X-Received: by 2002:a05:6512:203:b0:517:8ad8:c64 with SMTP id a3-20020a056512020300b005178ad80c64mr2433822lfo.21.1714758770135; Fri, 03 May 2024 10:52:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714758770; cv=pass; d=google.com; s=arc-20160816; b=VsW/dhENjxWPajZ6L+BQTdw7xL3MHf/tfoQGkD7nk2PGjz9aXVkFPNZ2BDw+H+d0Co b0zX6KuntKsfVG5DeImbhwL35lh9Bo5Lk+lsdHvwBl//jbs50+3qzYkm6GTC4xh+Fehm 9oxJvzVv+6RsBeSJfuGCDrpzmw/KEdTqMxThmdNUwNSrzx7jairCh2QVP1igd4esxhpK euGo1LKsX9mWJIzj0ysl+rt9x/Soa1u3mXeelSPIRBTYAmpZ/h7yrq3Cwd9f9HaFVxwW /dbLdPRknzQoDK7JZObNBWeJoymcdT4/SNgBY7XfVC7fW1tx27wcXo8uojfX96T8Iccp CNQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=S5Lj7EMp57A1ZOWJ8YtZlI8QLrZzM8FZK+WR00Wk7Lw=; fh=dMeH7MdfCo3c4jamSCTsasfxcDWCfdhwjmcm857OECQ=; b=Un9jVeFOeyjAJ03g6yXIqjyhfiTmmDbgJw0Jn66pgvA802NEk6+ubat0cEOlNUvwoX AaxqKX4ikUq/l3Uk0mVxgEDFdl2HVovtfgdqQMWqAoJGlcPC/nUsAcOiCha646V73olM W6gy6cXRo7fJiLGljZizKmNONCOwuUV9G49+Q6sS2KeHad38dlGRqfCaQ7huaybMdg/i 7qV8g3N270C0UYN5U2r6ZjCvcLrs2+ehntpnfqXfaBi9Q/Bq5bmzF49YD/EeP8B0xyJE uywfoHFuJFhrDjEVC5rmx9Xy+GRF+zSjkFaeBDNb2j1D15iWwh3Nc4DQh9hrbmekPEDu KPew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IoHu0LzS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u16-20020a170906b11000b00a58a732d7bdsi1777332ejy.116.2024.05.03.10.52.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=IoHu0LzS; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-167987-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167987-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D4C401F228A7 for ; Fri, 3 May 2024 17:52:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC058158215; Fri, 3 May 2024 17:52:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IoHu0LzS" Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72FB723749; Fri, 3 May 2024 17:52:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758760; cv=none; b=JztCjJjqMxhP75FlOyZi8iFIMhroOvjUXTYRUq8IvhF1x1V9H4lUItAk/hxaGEFhcV+gR5vP/cJxSnaBjjYG3V3JNHroxTGIMnrh0cikRX0BLAhflvaXj+68TYo5tO4Gf5H+wlmJj+tfdnqY4qUGorT6TiP28wmbU92jM+ttHL8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714758760; c=relaxed/simple; bh=26lFkDSslFUBARmxaoBwnZXKXDz1wLRsTHBw5LcZKiA=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=SZo6DDgcq+IilL7pykr30HssX6FELnLBIy/Fn2cgQ8xlpdkMfXfmgHCfTEtBNHEHRjkN8KUkRHvQJ88N4T11WQEvan3URdX665M9sBQBKNsAzdq45Mrgs7wdZ/bQLNFpYgBhYM6HBGgFuV9OpCs326zIAv156rGoP+QnbOO/kCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IoHu0LzS; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a524ecaf215so1367155466b.2; Fri, 03 May 2024 10:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714758757; x=1715363557; darn=vger.kernel.org; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:from:to:cc:subject:date:message-id:reply-to; bh=S5Lj7EMp57A1ZOWJ8YtZlI8QLrZzM8FZK+WR00Wk7Lw=; b=IoHu0LzSbZHf7Gh7zKARmfA1rYxElm9vc+uPZb+HvNwtIVyDgoB8Bq1GOKszmtb3EH UW+biTDMSIGWDo3N5DE1MQKTJTs0bgvl1AR3+UyozvqQQvUiwWJAzjVTncglP4iUYAbA LSgcP8pZij5cpi+ko0uLlB45Jqzhxq4RsxuDCLrB3TCarttgNk4Yp1mVOdgOZJQf+Kk4 f+vihmW6ljClYltz42j4clC/Q7gcAXbeIXzs/qr9TyDcYIKQswvqHy82NfY9aEpIPMmZ EEFPpH+pq1ncntS8qeJ10dIG/H7IWpnfy1DXrBdX6xaPGfg12eHslQb19ye2dQ3lNYHT fXOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714758757; x=1715363557; h=cc:to:content-transfer-encoding:mime-version:message-id:date :subject:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S5Lj7EMp57A1ZOWJ8YtZlI8QLrZzM8FZK+WR00Wk7Lw=; b=ZzL7fRuzSiJJxy8fxIXOhbPlDLHnO+8DcFUhipMujcZ1zLd4S4PNU1gxP0ODsQyMRf p6+a0A4lcdHWXKhVZH+TpTl6yo8GRYyZpIuOsUD6/aKjZGZc2iyBl8ErHc/ElAcWcEb3 hj/Gi0aqBTLLpPlfqCNbq7FydHo77WJJD7Iw7DkEHSA4x9KFBI4H7csVfO+utB0u1xmY r3wijwE+vZCGzfRCmov3bx/8POYELqP9amW/jPpgZ7Is1dLZaRqKBuZJ/hspUJg2YTx8 wDj+jnAHIsVzvhQJ1NrTGUB7+K5o0b4lqVlsQYEoNd27nEFGzFVmptZ5O7OIJqk1SA8y W5zQ== X-Forwarded-Encrypted: i=1; AJvYcCVYMeDulHuod8Zev7SgkgwmFhkdEBPMWpndU2aD9Pspi6FrBzM8FfHVWn13NoGF7s+Gm5vCPrMG5dxDc/0a9UsNKFVUhLyWX5SqySGm X-Gm-Message-State: AOJu0YwndnOahH8gtp3wR2WhExn0HYuiDynwmt9bUwdOmu3HpVKqATb3 ICgi88xUI1XRzWlzVz+HeS5P4rQFGoF1VlhJWNFLZseNQXIffwTi X-Received: by 2002:a50:a696:0:b0:568:d5e7:37a1 with SMTP id e22-20020a50a696000000b00568d5e737a1mr2215751edc.36.1714758756804; Fri, 03 May 2024 10:52:36 -0700 (PDT) Received: from [127.0.1.1] (84-115-213-47.cable.dynamic.surfer.at. [84.115.213.47]) by smtp.gmail.com with ESMTPSA id q28-20020a50aa9c000000b00572469a7948sm1968368edc.45.2024.05.03.10.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 10:52:36 -0700 (PDT) From: Javier Carrasco Subject: [PATCH 0/2] cpufreq: sun50i: fix memory leak and remove of_node_put() Date: Fri, 03 May 2024 19:52:31 +0200 Message-Id: <20240503-sun50i-cpufreq-nvmem-cleanup-v1-0-0a2352cac46b@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAF8kNWYC/x3MwQqDMAwA0F+RnBeIrpXhr8gOpaYa0Ky2VAbiv 1s8vss7IXMSzjA0JyQ+JMtPK9pXA35xOjPKVA0ddYYsvTEXtSToYwmJd9Rj4w39yk5LREPO+PA JzvYT1CImDvJ/+vF7XTdx4KIFbgAAAA== To: Yangtao Li , "Rafael J. Wysocki" , Viresh Kumar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andre Przywara , Jonathan Cameron Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1714758755; l=1729; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=26lFkDSslFUBARmxaoBwnZXKXDz1wLRsTHBw5LcZKiA=; b=SAyC1/2rpo7KrfqQ3wLlae9m8UXTOYb4VAe330AWXXwusl1ENis3BtDioVvV8r8YDz5yvQHKR QzpMy9YoqUzBxOEAK9wzbzCFss4+EKjtvl/cpdv2TW5D/WLnigd2ZJ6 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= This series fixes a memory leak by means of the _scoped version of the for_each_child_of_node() loop, which was recently introduced with 34af4554fb0c ("of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling"). The new approach is still not widely used, but this might be a good occasion to use it in a driver because it actually fixes a bug, and the loop is rather simple. The creator of the new macro was added to the discussion in case the new approach is still not mature enough, even for such simple case. Additionally, the existing uses of of_node_put() have been removed to favour the _free() cleanup handler, which reduces the chances of having any other memory leak because some of_node_put() is missing as well as simplifies the current code. I don't have the real hardware to test the series, so I "faked" the node in a device tree for an arm64 device (Rockchip) and hacked the driver to get to run dt_has_supported_hw(). The new implementation works as expected, but if someone wants to test it with the proper SoC, additional tests are always welcome. The same applies for the removals of of_node_put(). Signed-off-by: Javier Carrasco --- Javier Carrasco (2): cpufreq: sun50i: fix memory leak in dt_has_supported_hw() cpufreq: sun50i: replace of_node_put() with automatic cleanup handler drivers/cpufreq/sun50i-cpufreq-nvmem.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) --- base-commit: 9221b2819b8a4196eecf5476d66201be60fbcf29 change-id: 20240503-sun50i-cpufreq-nvmem-cleanup-40a4cf8fa56d Best regards, -- Javier Carrasco