On Mon, Mar 15, 2021 at 2:28 PM Joel Sherrill <j...@rtems.org> wrote: > > > > On Mon, Mar 15, 2021, 3:10 PM Gedare Bloom <ged...@rtems.org> wrote: >> >> On Fri, Mar 12, 2021 at 8:18 AM Ryan Long <ryan.l...@oarcorp.com> wrote: >> > >> > CID 1439297: Resource leak in rtems_nvdisk_initialize(). >> > >> > Closes #4298 >> > --- >> > cpukit/libblock/src/nvdisk.c | 8 +++++++- >> > 1 file changed, 7 insertions(+), 1 deletion(-) >> > >> > diff --git a/cpukit/libblock/src/nvdisk.c b/cpukit/libblock/src/nvdisk.c >> > index a7f4167..d742baf 100644 >> > --- a/cpukit/libblock/src/nvdisk.c >> > +++ b/cpukit/libblock/src/nvdisk.c >> > @@ -766,8 +766,10 @@ rtems_nvdisk_initialize (rtems_device_major_number >> > major RTEMS_UNUSED, >> > nvd->info_level = c->info_level; >> > >> > nvd->devices = calloc (c->device_count, sizeof >> > (rtems_nvdisk_device_ctl)); >> > - if (!nvd->devices) >> > + if (!nvd->devices) { >> > + free(nvd); >> > return RTEMS_NO_MEMORY; >> > + } >> > >> > for (device = 0; device < c->device_count; device++) >> > { >> > @@ -790,6 +792,8 @@ rtems_nvdisk_initialize (rtems_device_major_number >> > major RTEMS_UNUSED, >> > rtems_nvdisk_ioctl, nvd); >> > if (sc != RTEMS_SUCCESSFUL) >> > { >> > + free(nvd->devices); >> > + free(nvd); >> > rtems_nvdisk_error ("disk create phy failed"); >> > return sc; >> > } >> > @@ -797,5 +801,7 @@ rtems_nvdisk_initialize (rtems_device_major_number >> > major RTEMS_UNUSED, >> > rtems_mutex_init (&nvd->lock, "NV Disk"); >> > } >> > >> > + free(nvd->devices); >> > + free(nvd); >> >> Does the rtems_blkdev_create() link the nvd? (I think the answer is >> yes.) Then, this is not correct. > > > I think this is my suggestion so what do you think should happen on this case?
Does the block device driver register a callback handler for the device_data destruction? >> >> >> > return RTEMS_SUCCESSFUL; >> > } >> > -- >> > 1.8.3.1 >> > >> > _______________________________________________ >> > devel mailing list >> > devel@rtems.org >> > http://lists.rtems.org/mailman/listinfo/devel >> _______________________________________________ >> devel mailing list >> devel@rtems.org >> http://lists.rtems.org/mailman/listinfo/devel _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel