Commit 78f88067 authored by Aaron Thompson's avatar Aaron Thompson Committed by Danilo Krummrich
Browse files

drm/nouveau: Do not fail module init on debugfs errors



If CONFIG_DEBUG_FS is enabled, nouveau_drm_init() returns an error if it
fails to create the "nouveau" directory in debugfs. One case where that
will happen is when debugfs access is restricted by
CONFIG_DEBUG_FS_ALLOW_NONE or by the boot parameter debugfs=off, which
cause the debugfs APIs to return -EPERM.

So just ignore errors from debugfs. Note that nouveau_debugfs_root may
be an error now, but that is a standard pattern for debugfs. From
include/linux/debugfs.h:

"NOTE: it's expected that most callers should _ignore_ the errors
returned by this function. Other debugfs functions handle the fact that
the "dentry" passed to them could be an error and they don't crash in
that case. Drivers should generally work fine even if debugfs fails to
init anyway."

Fixes: 97118a18 ("drm/nouveau: create module debugfs root")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarAaron Thompson <dev@aaront.org>
Acked-by: default avatarTimur Tabi <ttabi@nvidia.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250703211949.9916-1-dev@aaront.org
parent 226862f5
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -314,14 +314,10 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
	drm->debugfs = NULL;
}

int
void
nouveau_module_debugfs_init(void)
{
	nouveau_debugfs_root = debugfs_create_dir("nouveau", NULL);
	if (IS_ERR(nouveau_debugfs_root))
		return PTR_ERR(nouveau_debugfs_root);

	return 0;
}

void
+2 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ extern void nouveau_debugfs_fini(struct nouveau_drm *);

extern struct dentry *nouveau_debugfs_root;

int  nouveau_module_debugfs_init(void);
void nouveau_module_debugfs_init(void);
void nouveau_module_debugfs_fini(void);
#else
static inline void
@@ -42,10 +42,9 @@ nouveau_debugfs_fini(struct nouveau_drm *drm)
{
}

static inline int
static inline void
nouveau_module_debugfs_init(void)
{
	return 0;
}

static inline void
+1 −3
Original line number Diff line number Diff line
@@ -1461,9 +1461,7 @@ nouveau_drm_init(void)
	if (!nouveau_modeset)
		return 0;

	ret = nouveau_module_debugfs_init();
	if (ret)
		return ret;
	nouveau_module_debugfs_init();

#ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
	platform_driver_register(&nouveau_platform_driver);