RTEMS | cpukit/libblock: Fix resource leak in rtems_nvdisk_initialize (CID 1439297) (!905)

MITHILESH MATTAPALLI (@mithileshm) gitlab at rtems.org
Thu Feb 5 16:35:26 UTC 2026




MITHILESH MATTAPALLI commented on a discussion on cpukit/libblock/src/nvdisk.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/905#note_141716

 >      nvd->info_level   = c->info_level;
 >  
 >      nvd->devices = calloc (c->device_count, sizeof (rtems_nvdisk_device_ctl));
 > -    if (!nvd->devices)
 > +    if (!nvd->devices) {
 > +      if (i > 0) {
 > +        rtems_nvdisk* p = nvd_start;
 > +        for (j = 0; j < i; ++j, ++p) {
 > +          free (p->devices);
 > +        }
 > +      }
 > +      free (nvd_start);

I have reviewed !906. I agree that Prakhar's use of a helper function is cleaner than the goto approach I took here. I also see that !906 addresses the name generation bug which I had missed.

Since his solution is more comprehensive and architecturally cleaner, I am closing this MR in favor of !906 to avoid redundancy. Thank you for the review.

-- 
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/905#note_141716
You're receiving this email because of your account on gitlab.rtems.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260205/f5393963/attachment.htm>


More information about the bugs mailing list