Skip to content

Possible bug in kfree() #10

@google0101-ryan

Description

@google0101-ryan

When kfree is called, it uses sizeof() to get the size of the pointer. However, if I'm remembering correctly, this will return the size of the pointer, not the size of the memory region. I would recommend adding a header above each region of memory to keep track of region sizes and the like. An example header could be:

typedef struct
{
    uint32_t size;
    int magic;
} mem_header_t;

You could then allocate a region of the requested size plus the size of the header, and insert one above the region allocated. The pointer returned would point to the memory beneath the header, so just subtract the size of the header from the pointer to get the header's address.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestkernelThis changes are in kernel

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions