From 03d2a12321f06036bf5a8a1cc51ee6d5956f536d Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 11 Nov 2016 20:04:19 +0000 Subject: [PATCH] MFC r308023: If the fatchain() call in chainalloc() returned an error, revert marking the cluster run as in-use. git-svn-id: svn://svn.freebsd.org/base/stable/10@308550 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/fs/msdosfs/msdosfs_fat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c index 5229aeab4..2e411474e 100644 --- a/sys/fs/msdosfs/msdosfs_fat.c +++ b/sys/fs/msdosfs/msdosfs_fat.c @@ -731,8 +731,11 @@ chainalloc(pmp, start, count, fillwith, retcluster, got) pmp->pm_nxtfree = CLUST_FIRST; pmp->pm_flags |= MSDOSFS_FSIMOD; error = fatchain(pmp, start, count, fillwith); - if (error != 0) + if (error != 0) { + for (cl = start, n = count; n-- > 0;) + usemap_free(pmp, cl++); return (error); + } #ifdef MSDOSFS_DEBUG printf("clusteralloc(): allocated cluster chain at %lu (%lu clusters)\n", start, count); -- 2.45.0