printbuf.buf may be NULL if allocation_failure is true. Check for this prior to using it as a seq_printf source.
Fixes: fa8e94faeece ("bcachefs: Heap allocate printbufs") Signed-off-by: David Disseldorp <dd...@suse.de> Signed-off-by: Hongbo Li <lihongb...@huawei.com> --- fs/bcachefs/fs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 91fce04272a1..4dbb46e41509 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -2048,13 +2048,18 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root) { struct bch_fs *c = root->d_sb->s_fs_info; struct printbuf buf = PRINTBUF; + int ret; bch2_opts_to_text(&buf, c->opts, c, c->disk_sb.sb, OPT_MOUNT, OPT_HIDDEN, OPT_SHOW_MOUNT_STYLE); printbuf_nul_terminate(&buf); - seq_printf(seq, ",%s", buf.buf); - int ret = buf.allocation_failure ? -ENOMEM : 0; + ret = printbuf_err(&buf); + if (ret) + goto err; + + seq_printf(seq, ",%s", buf.buf); +err: printbuf_exit(&buf); return ret; } -- 2.34.1