From 655247e0f5d689da4bda90e946a5227f58670ef2 Mon Sep 17 00:00:00 2001 From: fjoe Date: Tue, 23 Sep 2003 16:44:17 +0000 Subject: Do not cache and correctly free() dosmount entry in case of errors. PR: 53980 (partially) --- usr.bin/fstat/msdosfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'usr.bin/fstat') diff --git a/usr.bin/fstat/msdosfs.c b/usr.bin/fstat/msdosfs.c index 6766677..dda7d17 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); -- cgit v1.1