From nobody Mon Apr 6 20:28:34 2026 Received: from mail-dy1-f174.google.com (mail-dy1-f174.google.com [74.125.82.174]) (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 56931285CB6 for ; Wed, 18 Mar 2026 02:48:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773802125; cv=none; b=FepszU/nXKY55xhZnv6C7QhlZ0VUg56LP3rxGa4Je+Z0m0ZUnd5tWEcwpTpe2LTEW1kE7gyui9Cze6FbLl34E4Jxfy5H09Tn9sLF13UNOYNUNGUon61ZS3JEYAoExMugwJjOakYM5yE9jkxF7OMUpnAb67XubdaLlLVD2l8NV1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773802125; c=relaxed/simple; bh=b4GhCeYtl7uAbYl9+/ANPuQiNaXtSBWnV4gUaeDC3tQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ONkXiDywHOZgtk+PsH8vHK08QzeY/aW7FYnPsEDFsS/ZK3gyOe9aclYC4TXPZAI1cV4ZCBQisGL/oIh0Oj9LZDF2HBRacZ7XtiV/EcrGDqoPUUfODEB3FQIj2NAn2g7HfsTqtw4thiuocC2VT0OxZittQWuxuv9tpYeBmGDzykk= 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=DPd4mUYh; arc=none smtp.client-ip=74.125.82.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DPd4mUYh" Received: by mail-dy1-f174.google.com with SMTP id 5a478bee46e88-2beab594d8eso1662959eec.0 for ; Tue, 17 Mar 2026 19:48:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773802121; x=1774406921; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xz8/2qEt8vMzdZArROcCz49QpkswhVDh5Jy8LhjWhmU=; b=DPd4mUYhKb9Yywl9nMVOrnFWLExC3j9U9NuICuUVodvWizzDIceRM2569OR8T7+6wZ 4kSKDgU84nCXVguZZr3oZ0qu5WjTrMIrH+NBxUDZghYv2PGGr31DUIn+hYTErKfYrw5H kzOELSBHu/x6dcDVBI1kL8bFdQBp6Ls269Bn97dBdmIoiQ9CYK6iRRnTo9QrwKuXMA9W Y0R4GwJCOBTcgqCvgfji5ZLBQpKK3ktx7P3XxdhVHaqFMHPfY3B4nxIPXZCXLVDooxax LvipgpgozY1ly+LQarGbjlxTkgGdXZyu4oicHx1mxJy876jMw5RXbaP05+zbzyFpLYmK 83zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773802121; x=1774406921; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Xz8/2qEt8vMzdZArROcCz49QpkswhVDh5Jy8LhjWhmU=; b=cjdcKgcnveBME7WcXizUHik2cBZz3ffU5LnlG/OIgTZ+6BNky4EzKimkQlPd/ERoQ8 eh5FBy11p457yhT4qRP8mJ8lw+C+dTtZiQhhnkeMpj4NwhJKp8jkQxtQw2ffqrAEo4X6 GyqDmbFJl+WAPkM6dwFunW+Q+UL6jaQtlOQCL2dXcSmKi69k5BhnqBqXUJo3z/uQAjdD hW3fYGgU+4oxK+oRr+6jMnHKZxCA3AFglhwIglcnvRRxYHNMxp9rI1xbBOyfUjZbU+M6 dXQPurNbSYN1/kvrPWQ5o+ypNKgnGg3UfNHhEuan6aBgjvf6baDgAjWzjApwLngqZQxC 2DGQ== X-Forwarded-Encrypted: i=1; AJvYcCXdgJlVN9gaAALQmnJQ4ISjbwrCqcJl3rbrAAZCcEmVYtJW0xrpIqUD1KVSng/Fq4UbsdgfBp6W4ovskaQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzBd8SZHgk+F3ImuiJSqIAYOSyN0IQ1fEwE1GuJekjJf9fEivED S9GKGTfXIRD6IQyznCOU0iNge4ulSa9+bvvH9ELM5QRWTOW7YGFNNFAd X-Gm-Gg: ATEYQzwcVXwPbRWVh5zWCCbzCZxI1Vyya+9XLEGDClbh7m7l2DY4K5HJ1IuFahddLzE Y9F3pT+UHJCQp/Mb+M9xGIoMMNSNCzZbE0hzmSUgAkYSUvQmrDb1Phx+L73X5/468n+lu1Y91gx e07iMNRZJOI6KOl5dT8yBQ+SBRtMUm3R02vFhGXWJ7DYEFzwlDwUrAQjBVer0nGc492xu29JDwV BNENIhw6vNBt+5GZqVL4EgYpE/3TMENlpZXwFhgkOmUxePip1B9Q19TJc+ZwLsWUXunjaUIQTGK ch7IW5nZInYwkeCtln0fbMuiTIfygMmbBKJZsHDxgs27xNoEKVIGwDwbgkeZmeUYQFDEu7nxTe9 A5myGUnUHSb/GYAsfQmOwgZELfCa8Y/EEIUsYFxeqOqLJwVdWzj8e67kl21ObRqHIu6XGmdXSgT z1OSjQ58Eiyhy8U9fLlaVe2Tj3sl1Nvf8iTbXrETcIGWR3zxCuEqNxc7M5y4fxI+0TbpCJ7IWi7 HoOr9xUElEkzXb6S9oUW1Lg3pjKmgwdxSrHyN+BzI8uk6sCoeOzaltNyRfatClFEThYdhA5 X-Received: by 2002:a05:7300:ed0b:b0:2be:833c:1486 with SMTP id 5a478bee46e88-2c0e5020a54mr893060eec.18.1773802121076; Tue, 17 Mar 2026 19:48:41 -0700 (PDT) Received: from 2045L.localdomain (130.sub-75-229-251.myvzw.com. [75.229.251.130]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c0e55cd9cfsm1930911eec.26.2026.03.17.19.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2026 19:48:40 -0700 (PDT) From: Gui-Dong Han To: Georgi Djakov Cc: Kuan-Wei Chiu , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, akaieurus@gmail.com, me@ziyao.cc, Gui-Dong Han Subject: [PATCH] interconnect: debugfs: fix devm_kstrdup and kfree mismatch Date: Wed, 18 Mar 2026 10:48:15 +0800 Message-ID: <20260318024815.7655-1-hanguidong02@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" debugfs_write_file_str() uses standard kfree() to release old strings. Initializing src_node and dst_node with devm_kstrdup() creates a memory management mismatch. If a user writes to these debugfs nodes, the devm-allocated memory is freed via kfree(), leaving a dangling pointer in the device resource list that can lead to a double free. Fix this by using standard kstrdup() instead. Since the interconnect subsystem is strictly built-in and cannot be unloaded as a module, there is no exit path requiring manual cleanup of these strings. The error handling path is also simplified by taking advantage of the fact that kfree(NULL) is a safe no-op. Fixes: 8cc27f5c6dd1 ("interconnect: debugfs: initialize src_node and dst_no= de to empty strings") Signed-off-by: Gui-Dong Han Reviewed-by: Kuan-Wei Chiu --- I noticed this memory management mismatch while working on similar debugfs string initialization fixes [1] recently. [1] https://lore.kernel.org/driver-core/20260317185920.43387-1-hanguidong02= @gmail.com/ --- drivers/interconnect/debugfs-client.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/interconnect/debugfs-client.c b/drivers/interconnect/d= ebugfs-client.c index 5107bff53173..08df9188ef94 100644 --- a/drivers/interconnect/debugfs-client.c +++ b/drivers/interconnect/debugfs-client.c @@ -150,10 +150,13 @@ int icc_debugfs_client_init(struct dentry *icc_dir) return ret; } =20 - src_node =3D devm_kstrdup(&pdev->dev, "", GFP_KERNEL); - dst_node =3D devm_kstrdup(&pdev->dev, "", GFP_KERNEL); - if (!src_node || !dst_node) + src_node =3D kstrdup("", GFP_KERNEL); + dst_node =3D kstrdup("", GFP_KERNEL); + if (!src_node || !dst_node) { + kfree(dst_node); + kfree(src_node); return -ENOMEM; + } =20 client_dir =3D debugfs_create_dir("test_client", icc_dir); =20 --=20 2.43.0