installboot: explicit free() in bootstrap()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

installboot: explicit free() in bootstrap()

Michael Mikonos
Hello,

On hppa and landisk, bootstrap() is called from md_installboot().
md_installboot() is the last action before returning from main(),
but bootstrap() can explicitly free the buffer it calloc'd (boot).
I don't have access to hppa or landisk. Is someone able to check
that this doesn't break anything?

- Michael


Index: bootstrap.c
===================================================================
RCS file: /cvs/src/usr.sbin/installboot/bootstrap.c,v
retrieving revision 1.10
diff -u -p -u -r1.10 bootstrap.c
--- bootstrap.c 1 Sep 2018 16:55:29 -0000 1.10
+++ bootstrap.c 7 Nov 2018 15:15:31 -0000
@@ -124,7 +124,9 @@ bootstrap(int devfd, char *dev, char *bo
  fprintf(stderr, "%s bootstrap to disk\n",
     (nowrite ? "would write" : "writing"));
  if (nowrite)
- return;
+ goto done;
  if (pwrite(devfd, boot, bootsize, 0) != (ssize_t)bootsize)
  err(1, "pwrite");
+done:
+ free(boot);
 }