Commit 7b4ddfa7 authored by Chengyu Song's avatar Chengyu Song Committed by Bob Peterson

gfs2: incorrect check for debugfs returns

debugfs_create_dir and debugfs_create_file may return -ENODEV when debugfs
is not configured, so the return value should be checked against ERROR_VALUE
as well, otherwise the later dereference of the dentry pointer would crash
the kernel.
Signed-off-by: default avatarChengyu Song <>
Signed-off-by: default avatarBob Peterson <>
Acked-by: default avatarSteven Whitehouse <>
parent d9be0cda
......@@ -2047,34 +2047,41 @@ static const struct file_operations gfs2_sbstats_fops = {
int gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
sdp->debugfs_dir = debugfs_create_dir(sdp->sd_table_name, gfs2_root);
if (!sdp->debugfs_dir)
return -ENOMEM;
sdp->debugfs_dentry_glocks = debugfs_create_file("glocks",
struct dentry *dent;
dent = debugfs_create_dir(sdp->sd_table_name, gfs2_root);
if (IS_ERR_OR_NULL(dent))
goto fail;
sdp->debugfs_dir = dent;
dent = debugfs_create_file("glocks",
sdp->debugfs_dir, sdp,
if (!sdp->debugfs_dentry_glocks)
if (IS_ERR_OR_NULL(dent))
goto fail;
sdp->debugfs_dentry_glocks = dent;
sdp->debugfs_dentry_glstats = debugfs_create_file("glstats",
dent = debugfs_create_file("glstats",
sdp->debugfs_dir, sdp,
if (!sdp->debugfs_dentry_glstats)
if (IS_ERR_OR_NULL(dent))
goto fail;
sdp->debugfs_dentry_glstats = dent;
sdp->debugfs_dentry_sbstats = debugfs_create_file("sbstats",
dent = debugfs_create_file("sbstats",
sdp->debugfs_dir, sdp,
if (!sdp->debugfs_dentry_sbstats)
if (IS_ERR_OR_NULL(dent))
goto fail;
sdp->debugfs_dentry_sbstats = dent;
return 0;
return -ENOMEM;
return dent ? PTR_ERR(dent) : -ENOMEM;
void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp)
......@@ -2100,6 +2107,8 @@ void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp)
int gfs2_register_debugfs(void)
gfs2_root = debugfs_create_dir("gfs2", NULL);
if (IS_ERR(gfs2_root))
return PTR_ERR(gfs2_root);
return gfs2_root ? 0 : -ENOMEM;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment