Re: [PATCH] perf: Protect pmu device removal with pmu_bus_running check CONFIG_DEBUG_TEST_DRIVER_REMOVE kernel panic

CAI Qian
2016-10-20T14:31:06Z

> CAI Qian reported crash [1] in uncore device removal related
> to CONFIG_DEBUG_TEST_DRIVER_REMOVE option.
>
> The reason for crash is that perf_pmu_unregister tries to remove
> pmu device which is not added at this point. We add pmu devices
> only after pmu_bus is registered which happens in perf_event_sysfs_init
> init call and sets pmu_bus_running flag.
>
> The fix is to get the pmu_bus_running flag state at the point
> the pmu is taken out of the pmus list and remove the device
> later only if it's set.
>
> [1] https://marc.info/?l=linux-kernel&m=147688837328451
>
> Reported-by: CAI Qian <caiqian@redhat.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Tested-by: CAI Qian <caiqian@redhat.com>