Page MenuHomeFreeBSD

kern_intr: Check for NULL event in intr_destroy()
ClosedPublic

Authored by mhorne on Dec 15 2021, 5:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 11:46 PM
Unknown Object (File)
Feb 20 2024, 10:42 PM
Unknown Object (File)
Dec 21 2023, 7:14 AM
Unknown Object (File)
Dec 20 2023, 7:25 AM
Unknown Object (File)
Dec 10 2023, 8:32 PM
Unknown Object (File)
Sep 5 2023, 11:58 PM
Unknown Object (File)
Jul 7 2023, 4:09 AM
Unknown Object (File)
Jun 28 2023, 9:26 AM

Details

Summary

It likely won't happen, but is consistent with the other functions of
this KPI.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Dec 15 2021, 6:23 PM

Alas this came to my attention way to late to address on-time. Callers of intr_event_destroy() want to know whether everything has been appropriately released or not. If the event is NULL this likely something failed very early during setup. In such case the event doesn't need to be released since it was never allocated. As such 0 should be the return instead.

The other case is the current INTRNG where due to lazy allocation the event may or may not have been allocated by the time it is time to release. In such case if intr_event_destroy() is going to detect NULL then it simplifies callers to allow passing a pointer with unknown state.

Due to this D38602 now exists.

The actual situation is there are very few callers of intr_event_destroy(). Most calls assume it will succeed and fail to check the return. The likely course of action for many callers on error is to leak the pointer since there is no provision to cope with a failed release. If one is lucky printf() might be called.