[RTEMS Project] #3570: Resource leak in flashdisk.c (CID 1439298)
RTEMS trac
trac at rtems.org
Thu Oct 25 23:02:58 UTC 2018
#3570: Resource leak in flashdisk.c (CID 1439298)
------------------------+------------------------
Reporter: embeddedt | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone: Indefinite
Component: admin | Version: 6
Severity: normal | Keywords: Coverity
Blocked By: | Blocking:
------------------------+------------------------
Coverity Scan (https://scan.coverity.com/projects/rtems) reports a
resource leak in flashdisk.c. You need a Coverity Scan account and access
to the RTEMS project to see more details.
It appears that there are a cluster of issues here. The function tries to
allocate memory but when any single allocation fails, the previous
allocations are not freed.
Here is one example:
{{{
2496 fd->devices = calloc (c->device_count, sizeof
(rtems_fdisk_device_ctl));
2497 if (!fd->devices)
CID 1439298 (#1 of 2): Resource leak (RESOURCE_LEAK)
2498 return RTEMS_NO_MEMORY;
}}}
As you can see, on line 2498 it returns without freeing {{{fd}}} (which
was allocated on line 2457) and several other allocations in between these
lines.
Viewing CID 1439298 on Coverity Scan will give more details.
--
Ticket URL: <http://devel.rtems.org/ticket/3570>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list