<div dir="ltr"><div>On the surface, this looks OK to me. But I remember looking at this one</div><div>and wondering if there was any cleanup required because of the various</div><div>subroutine calls as you work down through this method.</div><div><br></div><div>Did you look into each of the subroutines called and make sure they</div><div>didn't do further allocations?</div><div><br></div><div>--joel</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 4, 2021 at 1:27 PM Harrison Edward Gerber <<a href="mailto:gerberhe11@gmail.com">gerberhe11@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">See also CID 1439298<br>
<br>
Closes #3570<br>
---<br>
cpukit/libblock/src/flashdisk.c | 16 ++++++++++++++++<br>
1 file changed, 16 insertions(+)<br>
<br>
diff --git a/cpukit/libblock/src/flashdisk.c b/cpukit/libblock/src/flashdisk.c<br>
index 91f99e0d52..4de6ecd807 100644<br>
--- a/cpukit/libblock/src/flashdisk.c<br>
+++ b/cpukit/libblock/src/flashdisk.c<br>
@@ -2486,17 +2486,29 @@ rtems_fdisk_initialize (rtems_device_major_number major,<br>
*/<br>
fd->copy_buffer = malloc (c->block_size);<br>
if (!fd->copy_buffer)<br>
+ {<br>
+ free(fd);<br>
return RTEMS_NO_MEMORY;<br>
+ }<br>
<br>
fd->blocks = calloc (blocks, sizeof (rtems_fdisk_block_ctl));<br>
if (!fd->blocks)<br>
+ {<br>
+ free(fd->copy_buffer);<br>
+ free(fd);<br>
return RTEMS_NO_MEMORY;<br>
+ }<br>
<br>
fd->block_count = blocks;<br>
<br>
fd->devices = calloc (c->device_count, sizeof (rtems_fdisk_device_ctl));<br>
if (!fd->devices)<br>
+ {<br>
+ free(fd->blocks);<br>
+ free(fd->copy_buffer);<br>
+ free(fd);<br>
return RTEMS_NO_MEMORY;<br>
+ }<br>
<br>
rtems_mutex_init (&fd->lock, "Flash Disk");<br>
<br>
@@ -2508,6 +2520,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,<br>
free (fd->copy_buffer);<br>
free (fd->blocks);<br>
free (fd->devices);<br>
+ free(fd);<br>
rtems_fdisk_error ("disk create phy failed");<br>
return sc;<br>
}<br>
@@ -2529,6 +2542,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,<br>
free (fd->copy_buffer);<br>
free (fd->blocks);<br>
free (fd->devices);<br>
+ free(fd);<br>
return RTEMS_NO_MEMORY;<br>
}<br>
<br>
@@ -2564,6 +2578,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,<br>
free (fd->copy_buffer);<br>
free (fd->blocks);<br>
free (fd->devices);<br>
+ free(fd);<br>
rtems_fdisk_error ("recovery of disk failed: %s (%d)",<br>
strerror (ret), ret);<br>
return ret;<br>
@@ -2577,6 +2592,7 @@ rtems_fdisk_initialize (rtems_device_major_number major,<br>
free (fd->copy_buffer);<br>
free (fd->blocks);<br>
free (fd->devices);<br>
+ free(fd);<br>
rtems_fdisk_error ("compacting of disk failed: %s (%d)",<br>
strerror (ret), ret);<br>
return ret;<br>
-- <br>
2.25.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div>