From ee4d316fe7c42e92084f9093230d7fde1a211013 Mon Sep 17 00:00:00 2001 From: Conrad Meyer Date: Wed, 7 Mar 2018 01:55:50 +0000 Subject: [PATCH] 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 --- sys/geom/part/g_part_gpt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index c2f772406614..ad68d0165a45 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -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); }