Author: cem
Date: Wed Mar  7 01:55:50 2018
New Revision: 330562
URL: https://svnweb.freebsd.org/changeset/base/330562

Log:
  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

Modified:
  head/sys/geom/part/g_part_gpt.c

Modified: head/sys/geom/part/g_part_gpt.c
==============================================================================
--- head/sys/geom/part/g_part_gpt.c     Wed Mar  7 01:55:38 2018        
(r330561)
+++ head/sys/geom/part/g_part_gpt.c     Wed Mar  7 01:55:50 2018        
(r330562)
@@ -923,6 +923,14 @@ g_part_gpt_read(struct g_part_table *basetable, struct
                    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);
        }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to