Changeset 625


Ignore:
Timestamp:
Jul 17, 2015, 4:34:54 PM (9 years ago)
Author:
guerin
Message:

fat32: check for fd allocation in _fat_close()

Could cause a negative refcount on an invalid inode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.c

    r624 r625  
    29552955//  -1  : "FAT not initialised"
    29562956//  -2  : "Illegal file descriptor"
    2957 //  -3  : "Cannot update DATA region for closed file"
    2958 //  -4  : "Cannot release memory"
     2957//  -3  : "File not open"
     2958//  -4  : "Cannot update DATA regions"
     2959//  -5  : "Cannot release memory"
    29592960/////////////////////////////////////////////////////////////////////////////////
    29602961int _fat_close( unsigned int fd_id )
     
    29752976    // takes lock
    29762977    _spin_lock_acquire( &_fat.fat_lock );
     2978
     2979    if( _fat.fd[fd_id].allocated == 0 )
     2980    {
     2981        _spin_lock_release( &_fat.fat_lock );
     2982        _printf("\n[FAT ERROR] in _fat_close() : file not open\n");
     2983        return -3;
     2984    }
    29772985
    29782986    // get the inode pointer
     
    29993007            _printf("\n[FAT ERROR] in _fat_close() : cannot write dirty clusters "
    30003008                    "for file <%s>\n", inode->name );
    3001             return -3;
     3009            return -4;
    30023010        }
    30033011
     
    30833091    if ( _fat.fd[fd_id].allocated == 0 )
    30843092    {
    3085         _printf("\n[FAT ERROR] in _fat_file_info() : file <%s> not open\n",
    3086                 _fat.fd[fd_id].inode->name );
     3093        _printf("\n[FAT ERROR] in _fat_file_info() : file not open\n");
    30873094        return -3;
    30883095    }
Note: See TracChangeset for help on using the changeset viewer.