Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in process.c process_load_for_slot #13

Open
JaihsonK opened this issue Dec 9, 2022 · 1 comment
Open

Memory leak in process.c process_load_for_slot #13

JaihsonK opened this issue Dec 9, 2022 · 1 comment

Comments

@JaihsonK
Copy link

JaihsonK commented Dec 9, 2022

Hi!
In PeachOS Master, there is a possible memory leak in process_load_for_slot.
Say we get an error on line 500:
`res = process_load_data(filename, _process);
if (res < 0)
{
goto out;
}

program_stack_ptr = kzalloc(PEACHOS_USER_PROGRAM_STACK_SIZE);
if (!program_stack_ptr) //line 500
{
    res = -ENOMEM;
    goto out;
}`

then process data needs to be freed. But this doesn't happen. As it stands, the out label acknowledges the need to free the data but doesn't do so:
`out:
if (ISERR(res))
{
if (_process && _process->task)
{
task_free(_process->task);
}

   // Free the process data
}`

A better implementation could be:
`if (ISERR(res))
{
if (_process && _process->task)
{
task_free(_process->task);
}

    // Free the process data
    process_free_program_data(_process);
}`
@nibblebits
Copy link
Owner

Your correct about the comment and forgetting to free the process data. Clearly I intended to do it and forgot, it will be corrected

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants