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

prov/efa: fix bug in error handling in efa_device_construct() #7806

Merged
merged 2 commits into from
Jun 7, 2022

Conversation

wzamazon
Copy link
Contributor

@wzamazon wzamazon commented Jun 6, 2022

In function efa_device_construct()'s error handling path, resources
(like ibv_ctx) were released, but the pointer was not reset to NULL,
which can caused double free. This patch addressed the issue.

Signed-off-by: Wei Zhang wzam@amazon.com

@shijin-aws
Copy link
Contributor

@wzamazon How can we test this bug fix?

@wzamazon
Copy link
Contributor Author

wzamazon commented Jun 6, 2022

I am writing a unit test that mock efadv_query_attr to return an error, which will trigger the bug.

@wzamazon wzamazon force-pushed the efa_fix_error_handling_in_open_device branch from 1a3cfcf to 0fd10cd Compare June 7, 2022 00:47
@wzamazon
Copy link
Contributor Author

wzamazon commented Jun 7, 2022

@shijin-aws I added a commit to include a unit test that mimic original bug, please review again.

efa_device_construct(&efa_device, 0, ibv_device_list[0]);

/* when error happend, efa_device.ibv_ctx should be NULL */
assert_null(efa_device.ibv_ctx);
Copy link
Contributor

@shijin-aws shijin-aws Jun 7, 2022

Choose a reason for hiding this comment

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

why not we check efa_device->rdm_info and efa_device->dgram_info as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense. added in new revision.

wzamazon added 2 commits June 7, 2022 03:44
This patch added a unit test for the error handling of function
efa_device_construct(), this is to reproduce the GitHub issue:

ofiwg#7805

Signed-off-by: Wei Zhang <wzam@amazon.com>
In function efa_device_construct()'s error handling path, resources
(like ibv_ctx) were released, but the pointer was not reset to NULL,
which can caused double free. This patch addressed the issue.

Signed-off-by: Wei Zhang <wzam@amazon.com>
@wzamazon wzamazon force-pushed the efa_fix_error_handling_in_open_device branch from 0fd10cd to 65eff4f Compare June 7, 2022 03:45
@wzamazon wzamazon requested a review from shijin-aws June 7, 2022 03:45
@wzamazon wzamazon merged commit 1fbb958 into ofiwg:main Jun 7, 2022
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

Successfully merging this pull request may close these issues.

2 participants