From 941b7dce0e4f59371eb6c3d70f34fee3e2a35507 Mon Sep 17 00:00:00 2001 From: Gopal Tiwari Date: Tue, 14 Dec 2021 19:45:18 +0800 Subject: [PATCH] nvme: fix NULL derefence in nvme_ctrl_fast_io_fail_tmo_show/store mainline inclusion from mainline-v5.13-rc1 commit d6609084b0b81abc74dc9db0281cdd0e074df5d4 category: bugfix bugzilla: NA CVE: NA Link: https://gitee.com/openeuler/kernel/issues/I4JFPM?from=project-issue ------------------------------------------------- Adding entry for dev_attr_fast_io_fail_tmo to avoid the kernel crash while reading and writing the fast_io_fail_tmo. Fixes: 09fbed636382 (nvme: export fast_io_fail_tmo to sysfs) Signed-off-by: Gopal Tiwari Reviewed-by: Keith Busch Signed-off-by: Christoph Hellwig Signed-off-by: jiangtao Reviewed-by: Hou Tao Signed-off-by: Yang Yingliang --- drivers/nvme/host/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d51285539385..36558dfe6f65 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3157,6 +3157,8 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj, return 0; if (a == &dev_attr_address.attr && !ctrl->ops->get_address) return 0; + if (a == &dev_attr_fast_io_fail_tmo.attr && !ctrl->opts) + return 0; return a->mode; } -- GitLab