diff --git a/kern/devmnt.c b/kern/devmnt.c index d03f41c..6924dc8 100644 --- a/kern/devmnt.c +++ b/kern/devmnt.c @@ -220,6 +220,16 @@ mntversion(Chan *c, char *version, int msize, int returnlen) m->msize = f.msize; unlock(&mntalloc.lk); + k = strlen(f.version); + if(returnlen > 0){ + if(returnlen < k) + error(Eshort); + memmove(version, f.version, k); + } + + poperror(); /* msg */ + free(msg); + lock(&m->lk); m->queue = 0; m->rip = 0; @@ -229,18 +239,9 @@ mntversion(Chan *c, char *version, int msize, int returnlen) m->c = c; unlock(&m->lk); - poperror(); /* msg */ poperror(); /* c */ qunlock(&c->umqlock); - k = strlen(f.version); - if(returnlen > 0){ - if(returnlen < k){ - free(msg); - error(Eshort); - } - memmove(version, f.version, k); - } free(msg); return k; }