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

leds: leds-lp5562 allow firmware files up to the maximum length

Firmware files are in ASCII, using 2 hex characters per byte. The
maximum length of a firmware string is therefore

16 (commands) * 2 (bytes per command) * 2 (characters per byte) = 64

Fixes: ff45262a85db ("leds: add new LP5562 LED driver")
Signed-off-by: Nick Stoughton <nstoughton@logitech.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>

authored by

Nick Stoughton and committed by
Jacek Anaszewski
ed2abfeb 79937a4b

+5 -1
+5 -1
drivers/leds/leds-lp5562.c
··· 260 260 { 261 261 const struct firmware *fw = chip->fw; 262 262 263 - if (fw->size > LP5562_PROGRAM_LENGTH) { 263 + /* 264 + * the firmware is encoded in ascii hex character, with 2 chars 265 + * per byte 266 + */ 267 + if (fw->size > (LP5562_PROGRAM_LENGTH * 2)) { 264 268 dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n", 265 269 fw->size); 266 270 return;