diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -616,8 +616,10 @@ } } if (sbuf_done(req->serror)) { - copyout(sbuf_data(req->serror), req->error, + nerror = copyout(sbuf_data(req->serror), req->error, imin(req->lerror, sbuf_len(req->serror) + 1)); + if (nerror != 0 && req->nerror == 0) + req->nerror = nerror; } nerror = req->nerror;