HomeFreeBSD

linuxkpi: Allow ida_destroy and idr_destroy to be called multiple times

Description

linuxkpi: Allow ida_destroy and idr_destroy to be called multiple times

This fixes some weird behavior triggered by nvidia-drm.ko: some DRM
cleanup functions will be called multiple times, leading to a double
free. drm_mode_config_cleanup will be called twice, causing ida_destroy
to be called twice. Although calling the cleanup twice doesn't seem
very clean, on Linux this seems to be permissable as it handles it
just fine. Not doing these checks causes mutex panics and double frees.

In order to preserve this behavior this change checks if the objects
have already been destroyed and bails if so. This fixes the panic seen
when unloading the nvidia-drm driver.

MFC after: 1 week
Reviewed by: bz, manu
Differential revision: https://reviews.freebsd.org/D44865

Details

Provenance
ashafer_badland.ioAuthored on Thu, Jun 6, 8:42 PM
wulfCommitted on Thu, Jun 6, 8:42 PM
Reviewer
bz
Differential Revision
D44865: linuxkpi: Allow ida_destroy and idr_destroy to be called multiple times
Parents
rG21f4cf5ccf87: LinuxKPI: lockdep_assert: wrong 'cond' used in WARN_ON MACRO
Branches
Unknown
Tags
Unknown