[PATCH] drm/gem: Fix resource leaks in drm_gem_huge_mnt_create() error paths
From: yaolu
Date: Mon Jun 08 2026 - 22:25:31 EST
From: Lu Yao <yaolu@xxxxxxxxxx>
Fix two resource leaks in error handling paths:
- Release filesystem type reference obtained by get_fs_type()
- Release fs_context allocated by fs_context_for_mount()
Fixes: 6e0b1b82017b ("drm/gem: Add huge tmpfs mountpoint helpers")
Signed-off-by: Lu Yao <yaolu@xxxxxxxxxx>
---
drivers/gpu/drm/drm_gem.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 3b2448a3a9de..6568fbdc4641 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -122,19 +122,24 @@ int drm_gem_huge_mnt_create(struct drm_device *dev, const char *value)
if (unlikely(!type))
return -EOPNOTSUPP;
fc = fs_context_for_mount(type, SB_KERNMOUNT);
+ put_filesystem(type);
if (IS_ERR(fc))
return PTR_ERR(fc);
ret = vfs_parse_fs_string(fc, "source", "tmpfs");
if (unlikely(ret))
- return -ENOPARAM;
+ goto err;
ret = vfs_parse_fs_string(fc, "huge", value);
if (unlikely(ret))
- return -ENOPARAM;
+ goto err;
dev->huge_mnt = fc_mount_longterm(fc);
put_fs_context(fc);
return drmm_add_action_or_reset(dev, drm_gem_huge_mnt_free, NULL);
+
+err:
+ put_fs_context(fc);
+ return -ENOPARAM;
}
EXPORT_SYMBOL_GPL(drm_gem_huge_mnt_create);
#endif
--
2.25.1