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

bhyve/acpi.c: return ENOMEM instead of EFAULT and call free() after being used #1016

Closed
wants to merge 1 commit into from

Conversation

rilysh
Copy link
Contributor

@rilysh rilysh commented Jan 8, 2024

  1. In basl_load() function, when allocation fails, it returns an EFAULT instead of ENOMEM. An EFAULT can mislead in some scenarios, whereas an ENOMEM for an allocation function makes much more sense.

  2. Call free() on addr, as it's not being used anymore after the basl_table_append_bytes() function.

…eing use

1. In basl_load() function, when allocation fails,
it returns an EFAULT instead of ENOMEM. An EFAULT
can mislead in some scenarios, whereas an ENOMEM
for an allocation function makes much more sense.

2. Call free() on addr, as it's not being used
anymore after the basl_table_append_bytes()
function.

Signed-off-by: rilysh <[email protected]>
@rilysh rilysh requested a review from bsdjhb as a code owner January 8, 2024 06:11
Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 this seems sensible

@markjdb
Copy link
Member

markjdb commented Jan 16, 2024

This seems ok. There are other leaks, e.g., if the BASL_EXEC bodies fail, we will leak addr, but that's going to be a fatal error anyway. This patch would at least placate static analyzers.

markjdb pushed a commit to markjdb/freebsd that referenced this pull request Jan 16, 2024
1. In basl_load() function, when allocation fails,
it returns an EFAULT instead of ENOMEM. An EFAULT
can mislead in some scenarios, whereas an ENOMEM
for an allocation function makes much more sense.

2. Call free() on addr, as it's not being used
anymore after the basl_table_append_bytes()
function.

Signed-off-by: rilysh <[email protected]>

MFC after:	1 week
Pull Request:	freebsd/freebsd-src#1016
@markjdb markjdb added the merged label Jan 16, 2024
@markjdb
Copy link
Member

markjdb commented Jan 16, 2024

Merged, thanks.

@markjdb markjdb closed this Jan 16, 2024
freebsd-git pushed a commit that referenced this pull request Jan 25, 2024
1. In basl_load() function, when allocation fails,
it returns an EFAULT instead of ENOMEM. An EFAULT
can mislead in some scenarios, whereas an ENOMEM
for an allocation function makes much more sense.

2. Call free() on addr, as it's not being used
anymore after the basl_table_append_bytes()
function.

Signed-off-by: rilysh <[email protected]>

MFC after:	1 week
Pull Request:	#1016

(cherry picked from commit e2e9568)
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Mar 15, 2024
1. In basl_load() function, when allocation fails,
it returns an EFAULT instead of ENOMEM. An EFAULT
can mislead in some scenarios, whereas an ENOMEM
for an allocation function makes much more sense.

2. Call free() on addr, as it's not being used
anymore after the basl_table_append_bytes()
function.

Signed-off-by: rilysh <[email protected]>

MFC after:	1 week
Pull Request:	freebsd/freebsd-src#1016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants