Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

leds: qcom-lpg: Check for array overflow when selecting the high resolution

When selecting the high resolution values from the array, FIELD_GET() is
used to pull from a 3 bit register, yet the array being indexed has only
5 values in it. Odds are the hardware is sane, but just to be safe,
properly check before just overflowing and reading random data and then
setting up chip values based on that.

Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/2026021934-nearby-playroom-036b@gregkh
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Greg Kroah-Hartman and committed by
Lee Jones
d45963a9 437536ca

+6 -1
+6 -1
drivers/leds/rgb/leds-qcom-lpg.c
··· 1273 1273 return ret; 1274 1274 1275 1275 if (chan->subtype == LPG_SUBTYPE_HI_RES_PWM) { 1276 - refclk = lpg_clk_rates_hi_res[FIELD_GET(PWM_CLK_SELECT_HI_RES_MASK, val)]; 1276 + unsigned int clk_idx = FIELD_GET(PWM_CLK_SELECT_HI_RES_MASK, val); 1277 + 1278 + if (clk_idx >= ARRAY_SIZE(lpg_clk_rates_hi_res)) 1279 + return -EINVAL; 1280 + 1281 + refclk = lpg_clk_rates_hi_res[clk_idx]; 1277 1282 resolution = lpg_pwm_resolution_hi_res[FIELD_GET(PWM_SIZE_HI_RES_MASK, val)]; 1278 1283 } else { 1279 1284 refclk = lpg_clk_rates[FIELD_GET(PWM_CLK_SELECT_MASK, val)];