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:
cem 2018-03-07 01:55:50 +00:00
parent 21aa322881
commit b3df8f9162

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);
}