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
This commit is contained in:
Konstantin Belousov 2016-10-28 11:26:44 +00:00
parent f33d62b2d2
commit 03b8a419e4

View File

@ -691,8 +691,11 @@ chainalloc(struct msdosfsmount *pmp, u_long start, u_long count,
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);