From 8a1186a25feccb9facc45050dc5587cad70cbe1e Mon Sep 17 00:00:00 2001 From: seteiro <276597748+cms19859230182-lang@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:19:52 +0800 Subject: [PATCH] [dfs][ptyfs] free pts file on unregister Fix #12023 In ptyfs_unregister_pts(), when a pts file is removed from the root directory list and its ptsno is returned to the bitmap pool, the allocated struct ptyfs_file was not freed, resulting in a kernel memory leak on every ptmx close. Free pts_file via rt_free() after safely detaching it from the superblock root list and returning the ptsno. --- components/dfs/dfs_v2/filesystems/ptyfs/ptyfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/components/dfs/dfs_v2/filesystems/ptyfs/ptyfs.c b/components/dfs/dfs_v2/filesystems/ptyfs/ptyfs.c index 75bffdf510da..d2b21a43a31a 100644 --- a/components/dfs/dfs_v2/filesystems/ptyfs/ptyfs.c +++ b/components/dfs/dfs_v2/filesystems/ptyfs/ptyfs.c @@ -303,6 +303,7 @@ rt_err_t ptyfs_unregister_pts(rt_device_t ptmx, ptsno_t ptsno) ptyfile_remove_from_root(sb, pts_file); ptsno_pool = &sb->ptsno_pool; rid_bitmap_put(ptsno_pool, ptsno); + rt_free(pts_file); rc = 0; } else