[Bug 1242] New: errant free in imfs_rmnod.c

rtems-bugs at rtems.org rtems-bugs at rtems.org
Mon May 7 13:08:25 UTC 2007


           Summary: errant free in imfs_rmnod.c
           Product: RTEMS
           Version: 4.7
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: major
          Priority: P3
         Component: filesystem
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: ralf.corsepius at rtems.org

Near to the end of cpukit/libfs/src/imfs/imfs_rmnod.c, this code can be found:

    if ( the_jnode->type == IMFS_SYM_LINK ) {
      if ( the_jnode->info.sym_link.name )
        free( the_jnode->info.sym_link.name );
    free( the_jnode );

GCC warns about it:
In function 'IMFS_rmnod':
warning: passing argument 1 of 'free' discards qualifiers from pointer target

AFAIU, the_jnode->info.sym_link.name is a "const char*", i.e. it contains the
address, but doesn't own the string.
=> the "free( the_jnode->info.sym_link.name );" is very likely wrong, and
likely to cause memory faults.

Configure bugmail: http://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.

More information about the bugs mailing list