svn commit: r308023 - head/sys/fs/msdosfs

Konstantin Belousov kib at FreeBSD.org
Fri Oct 28 11:26:45 UTC 2016


Author: kib
Date: Fri Oct 28 11:26:44 2016
New Revision: 308023
URL: https://svnweb.freebsd.org/changeset/base/308023

Log:
  If the fatchain() call in chainalloc() returned an error, revert
  marking the cluster run as in-use.
  
  Tested by:	pho
  Sponsored by:	The FreeBSD Foundation
  MFC after:	2 weeks

Modified:
  head/sys/fs/msdosfs/msdosfs_fat.c

Modified: head/sys/fs/msdosfs/msdosfs_fat.c
==============================================================================
--- head/sys/fs/msdosfs/msdosfs_fat.c	Fri Oct 28 11:23:36 2016	(r308022)
+++ head/sys/fs/msdosfs/msdosfs_fat.c	Fri Oct 28 11:26:44 2016	(r308023)
@@ -691,8 +691,11 @@ chainalloc(struct msdosfsmount *pmp, u_l
 		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);


More information about the svn-src-head mailing list