Changeset ad37630 in rtems


Ignore:
Timestamp:
Jun 21, 2010, 4:27:37 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
d8af86b
Parents:
0b95fb8
Message:

2010-06-21 Joel Sherrill <joel.sherrilL@…>

PR 1554/cpukit
Coverity Id 17

  • libi2c/libi2c.c, score/src/objectextendinformation.c: Fix memory leak on error.
Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r0b95fb8 rad37630  
     12010-06-21      Joel Sherrill <joel.sherrilL@OARcorp.com>
     2
     3        PR 1554/cpukit
     4        Coverity Id 17
     5        * libi2c/libi2c.c, score/src/objectextendinformation.c: Fix memory leak
     6        on error.
     7
    182010-06-21      Joel Sherrill <joel.sherrilL@OARcorp.com>
    29
  • cpukit/libi2c/libi2c.c

    r0b95fb8 rad37630  
    390390  struct stat sbuf;
    391391
     392  if (nmcpy == NULL) {
     393    safe_printf ( DRVNM "No memory\n");
     394    return -RTEMS_NO_MEMORY;
     395  }
     396
    392397  strcpy (nmcpy, name ? name : "/dev/i2c");
    393 
    394398
    395399  /* check */
    396400  if ('/' != *nmcpy) {
    397401    safe_printf ( DRVNM "Bad name: must be an absolute path starting with '/'\n");
     402    free( nmcpy );
    398403    return -RTEMS_INVALID_NAME;
    399404  }
     
    401406  if (!stat (nmcpy, &sbuf)) {
    402407    safe_printf ( DRVNM "Bad name: file exists already\n");
     408    free( nmcpy );
    403409    return -RTEMS_INVALID_NAME;
    404410  }
     
    413419    safe_printf ( DRVNM "Get %s status failed: %s\n",
    414420             nmcpy, strerror(errno));
     421    free( nmcpy );
    415422    return -RTEMS_INVALID_NAME;
    416423  }
     
    420427  if (libmutex == RTEMS_ID_NONE) {
    421428    safe_printf ( DRVNM "Library not initialized\n");
     429    free( nmcpy );
    422430    return -RTEMS_NOT_DEFINED;
    423431  }
     
    425433  if (bus == NULL || bus->size < sizeof (*bus)) {
    426434    safe_printf ( DRVNM "No bus-ops or size too small -- misconfiguration?\n");
     435    free( nmcpy );
    427436    return -RTEMS_NOT_CONFIGURED;
    428437  }
  • cpukit/score/src/objectextendinformation.c

    r0b95fb8 rad37630  
    5757  size_t            block_size;
    5858  void             *new_object_block;
    59 
    60   /*
    61    *  Search for a free block of indexes. The block variable ends up set
    62    *  to block_count + 1 if the table needs to be extended.
    63    */
     59  bool              do_extend;
     60
     61  /*
     62   *  Search for a free block of indexes. If we do NOT need to allocate or
     63   *  extend the block table, then we will change do_extend.
     64   */
     65  do_extend     = true;
    6466  minimum_index = _Objects_Get_index( information->minimum_id );
    6567  index_base    = minimum_index;
     
    7375
    7476    for ( ; block < block_count; block++ ) {
    75       if ( information->object_blocks[ block ] == NULL )
     77      if ( information->object_blocks[ block ] == NULL ) {
     78        do_extend = false;
    7679        break;
    77       else
     80      } else
    7881        index_base += information->allocation_size;
    7982    }
     
    105108
    106109  /*
    107    *  If the index_base is the maximum we need to grow the tables.
    108    */
    109   if (index_base >= information->maximum ) {
     110   *  Do we need to grow the tables?
     111   */
     112  if ( do_extend ) {
    110113    ISR_Level         level;
    111114    void            **object_blocks;
Note: See TracChangeset for help on using the changeset viewer.