diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index e10fc1da7..72b87251c 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -420,8 +420,12 @@ void bch2_opt_to_text(struct printbuf *out, case BCH_OPT_STR: if (flags & OPT_SHOW_FULL_LIST) prt_string_option(out, opt->choices, v); - else - prt_str(out, opt->choices[v]); + else { + if (opt->choices[v] == NULL) + pr_err("Invalid flags or index v passed to the function\n"); + else + prt_str(out, opt->choices[v]); + } break; case BCH_OPT_FN: opt->fn.to_text(out, c, sb, v);