leds: flash: qcom: correct the cleanup indexing
cover leds: flash: qcom: correct the cleanup indexing
The cleanup of the qcom flash controller walks the LEDs that are registered with it and frees the slots it finds. It counted the entries first and decremented the count before it used the index, so the last entry was left registered and the next registration of an LED reused that slot.
The cleanup also stopped at the first NULL slot. A torch-only LED, and a configuration without the V4L2 wrapper, leave NULL entries behind, and v4l2_flash_release() already accepts them. The cleanup now releases every slot that is registered and ignores the empty ones.
The fix was found on the Xiaomi Pad 8 Pro, whose camera flash uses this controller. The commit was prepared by slwyts for the support of the Focus Pen Pro; the original commit and its address are in the message of the patch itself.
---
2.43.0