1
0
Fork 0

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: ff45262a85 ("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>
alistair/sunxi64-5.4-dsi
Nick Stoughton 2019-07-17 14:56:06 -07:00 committed by Jacek Anaszewski
parent 79937a4bee
commit ed2abfebb0
1 changed files with 5 additions and 1 deletions

View File

@ -260,7 +260,11 @@ static void lp5562_firmware_loaded(struct lp55xx_chip *chip)
{
const struct firmware *fw = chip->fw;
if (fw->size > LP5562_PROGRAM_LENGTH) {
/*
* the firmware is encoded in ascii hex character, with 2 chars
* per byte
*/
if (fw->size > (LP5562_PROGRAM_LENGTH * 2)) {
dev_err(&chip->cl->dev, "firmware data size overflow: %zu\n",
fw->size);
return;