Fix NULL pointer dereference in dsl_deadlist_close() after error - #18875
Fix NULL pointer dereference in dsl_deadlist_close() after error#18875ryao wants to merge 1 commit into
Conversation
c33a55b allowed dsl_deadlist_open() to return errors. However, when dsl_deadlist_open() returns an error, dsl_deadlist_close() is called. If the error is from dmu_bonus_hold(), dsl_deadlist_close() will call dmu_buf_rele() on a NULL pointer. Closes openzfs#17809 Reported-by: Grok 4.5 Build Beta Signed-off-by: Richard Yao <richard@ryao.dev>
amotin
left a comment
There was a problem hiding this comment.
I don't strongly object it this way, but I think it would be cleaner if dsl_deadlist_open() itself also done some cleanup on error, so that dsl_deadlist_is_open() could return false and dsl_deadlist_close() would not be called on something half-initialized.
@amotin That would require making code changes in a number of places, because the way that the codebase is written calls Note that |
As I see,
It might be even better there already, since after failed |
Motivation and Context
c33a55b allowed dsl_deadlist_open() to return errors. However, when dsl_deadlist_open() returns an error, dsl_deadlist_close() is called. If the error is from dmu_bonus_hold(), dsl_deadlist_close() will call dmu_buf_rele() on a NULL pointer.
Closes #17809
Description
We check for a NULL pointer and refrain from calling
dmu_buf_rele()if we have one. This should fix the issue, since the pointer should be zero-initialized and remain that way unless a valid address is assigned to it.Grok 4.5 Build Beta found this bug.
How Has This Been Tested?
The buildbot can test.
Types of Changes
Checklist
Signed-off-by.