diff --git a/usr.bin/fstat/msdosfs.c b/usr.bin/fstat/msdosfs.c index 67666779179d..dda7d17b60bd 100644 --- a/usr.bin/fstat/msdosfs.c +++ b/usr.bin/fstat/msdosfs.c @@ -100,15 +100,16 @@ msdosfs_filestat(vp, fsp) if (!mnt) { if ((mnt = malloc(sizeof(struct dosmount))) == NULL) err(1, NULL); - mnt->next = mounts; - mounts = mnt; - mnt->kptr = denode.de_pmp; if (!KVM_READ(denode.de_pmp, &mnt->data, sizeof mnt->data)) { + free(mnt); dprintf(stderr, "can't read mount info at %p for pid %d\n", (void *)denode.de_pmp, Pid); return 0; } + mnt->next = mounts; + mounts = mnt; + mnt->kptr = denode.de_pmp; } fsp->fsid = dev2udev(denode.de_dev);