g_part_gpt: Fix memory leak in error path

If g_part_gpt_read() encountered a disk with bad primary and secondary
tables, it could leak memory.

Reported by:	Coverity
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2018-03-07 01:55:50 +00:00
parent fdee29d7d5
commit ee4d316fe7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330562

View File

@ -923,6 +923,14 @@ g_part_gpt_read(struct g_part_table *basetable, struct g_consumer *cp)
pp->name);
printf("GEOM: %s: GPT rejected -- may not be recoverable.\n",
pp->name);
if (prihdr != NULL)
g_free(prihdr);
if (pritbl != NULL)
g_free(pritbl);
if (sechdr != NULL)
g_free(sechdr);
if (sectbl != NULL)
g_free(sectbl);
return (EINVAL);
}