[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


http://www.rtems.org/bugzilla/show_bug.cgi?id=1242

           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:
../../../../../../../rtems.orig/c/src/../../cpukit/libfs/src/imfs/imfs_rmnod.c:
In function 'IMFS_rmnod':
../../../../../../../rtems.orig/c/src/../../cpukit/libfs/src/imfs/imfs_rmnod.c:76:
warning: passing argument 1 of 'free' discards qualifiers from pointer target
type


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 are the assignee for the bug, or are watching the assignee.



More information about the bugs mailing list