• Maarten Zanders's avatar
    leds: lp5523: fix out-of-bounds bug in lp5523_selftest() · 17c13c72
    Maarten Zanders authored
    When not all LED channels of the led chip are configured, the
    sysfs selftest functionality gives erroneous results and tries to
    test all channels of the chip.
    There is a potential for LED overcurrent conditions since the
    test current will be set to values from out-of-bound regions.
    
    It is wrong to use pdata->led_config[i].led_current to skip absent
    channels as led_config[] only contains the configured LED channels.
    
    Instead of iterating over all the physical channels of the device,
    loop over the available LED configurations and use led->chan_nr to
    access the correct i2c registers. Keep the zero-check for the LED
    current as existing users might depend on this to disable a channel.
    Reported-by: default avatarArne Staessen <a.staessen@televic.com>
    Signed-off-by: default avatarMaarten Zanders <maarten.zanders@mind.be>
    Signed-off-by: default avatarPavel Machek <pavel@ucw.cz>
    17c13c72
leds-lp5523.c 23.7 KB