mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
Fix clearing geom metadata if DIOCGSECTORSIZE fails
An unhandled error case would result in passing SIZE_MAX to malloc. While I'm here, remove an unnecessary NULL check before free Reported by: Coverity CID: 1017793 MFC after: 3 weeks Sponsored by: Spectra Logic Corp
This commit is contained in:
parent
48fe926362
commit
fc9437c886
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=316530
@ -336,7 +336,7 @@ g_metadata_clear(const char *name, const char *magic)
|
||||
goto out;
|
||||
}
|
||||
sectorsize = g_sectorsize(fd);
|
||||
if (sectorsize == 0) {
|
||||
if (sectorsize <= 0) {
|
||||
error = errno;
|
||||
goto out;
|
||||
}
|
||||
@ -365,8 +365,7 @@ g_metadata_clear(const char *name, const char *magic)
|
||||
}
|
||||
(void)g_flush(fd);
|
||||
out:
|
||||
if (sector != NULL)
|
||||
free(sector);
|
||||
free(sector);
|
||||
g_close(fd);
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user