RTEMS | cpukit/libblock: Fix resource leak in rtems_fdisk_initialize (!903)
MITHILESH MATTAPALLI (@mithileshm)
gitlab at rtems.org
Fri Mar 13 13:19:39 UTC 2026
MITHILESH MATTAPALLI commented on a discussion on cpukit/libblock/src/flashdisk.c: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/903#note_145330
> */
> +static void rtems_fdisk_cleanup_resources(
> + rtems_flashdisk *fds,
> + uint32_t minor,
> + rtems_flashdisk *fd
> +)
> +{
> + uint32_t i;
> +
> + for ( i = 0; i < minor; i++ ) {
> + rtems_flashdisk *p = &fds[ i ];
> + uint32_t d;
> + char clean_name[] = RTEMS_FLASHDISK_DEVICE_BASE_NAME "a";
> +
> + clean_name[ sizeof( RTEMS_FLASHDISK_DEVICE_BASE_NAME ) - 1 ] += i;
> + unlink( clean_name );
This cleans up the `/dev/fdisk*` nodes registered in the earlier successful loop iterations so we don't leave dangling pointers when `fds` is freed
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/903#note_145330
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/20260313/ead4e18d/attachment-0001.htm>
More information about the bugs
mailing list