Skip to contentSkip to conversation

blk-mq: protect debugfs_create_files() from failures

PATCH New Greg Kroah-Hartman 1 participant 1 message Jan 23, 2019 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blk-mq: protect debugfs_create_files() from failures

If debugfs were to return a non-NULL error for a debugfs call, using that pointer later in debugfs_create_files() would crash.

Fix that by properly checking the pointer before referencing it.

---
 block/blk-mq-debugfs.c | 3 +++
 1 file changed, 3 insertions(+)
block/blk-mq-debugfs.c +3 -0
index 90d68760af08..777638f597aa 100644
@@ -838,6 +838,9 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_ctx_attrs[] = {
 static bool debugfs_create_files(struct dentry *parent, void *data,
 				 const struct blk_mq_debugfs_attr *attr)
 {
+	if (IS_ERR_OR_NULL(parent))
+		return false;
+
 	d_inode(parent)->i_private = data;
 
 	for (; attr->name; attr++) {
Signature · 1 line
2.20.1