Changeset d91d076 in mainline


Ignore:
Timestamp:
2025-05-23T21:38:48Z (4 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
c44b399
Parents:
f62c901
Message:

ext4: write: fix block leak

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/ops.c

    rf62c901 rd91d076  
    6565static errno_t ext4_instance_get(service_id_t, ext4_instance_t **);
    6666static errno_t handle_sparse_or_unallocated_fblock(ext4_filesystem_t *,
    67     ext4_inode_ref_t *, uint32_t, uint32_t, uint32_t *, int *);
     67    ext4_inode_ref_t *, uint32_t, uint32_t, uint32_t *, int *, bool *);
    6868
    6969/* Forward declarations of ext4 libfs operations. */
     
    12881288        fs_node_t *fn;
    12891289        errno_t rc2;
     1290        bool fblock_allocated = false;
     1291
    12901292        errno_t rc = ext4_node_get(&fn, service_id, index);
    12911293        if (rc != EOK)
     
    13271329        if (fblock == 0) {
    13281330                rc = handle_sparse_or_unallocated_fblock(fs, inode_ref,
    1329                     block_size, iblock, &fblock, &flags);
     1331                    block_size, iblock, &fblock, &flags, &fblock_allocated);
    13301332                if (rc != EOK) {
    13311333                        async_answer_0(&call, rc);
     
    13701372
    13711373exit:
     1374        if (rc != EOK && fblock_allocated)
     1375                ext4_balloc_free_block(inode_ref, fblock);
     1376
    13721377        rc2 = ext4_node_put(fn);
    13731378        return rc == EOK ? rc2 : rc;
     
    13821387 * @param fblock        Place to store allocated block address
    13831388 * @param flags         BLOCK_FLAGS to update
     1389 * @param allocated     Place to store whether new block was allocated
    13841390 *
    13851391 * @return Error code
     
    13881394static errno_t handle_sparse_or_unallocated_fblock(ext4_filesystem_t *fs,
    13891395    ext4_inode_ref_t *inode_ref, uint32_t block_size, uint32_t iblock,
    1390     uint32_t *fblock, int *flags)
     1396    uint32_t *fblock, int *flags, bool *allocated)
    13911397{
    13921398        errno_t rc;
     
    14221428                        return rc;
    14231429                }
     1430
     1431                *allocated = true;
    14241432        }
    14251433
Note: See TracChangeset for help on using the changeset viewer.