mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
backlight: led_bl: Use devm_kcalloc() for array space allocation
Replace calls of devm_kzalloc() with devm_kcalloc() in led_bl_get_leds() and led_bl_parse_levels() for safer memory allocation with built-in overflow protection. Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org> Link: https://lore.kernel.org/r/20250819035804.433615-1-rongqianfeng@vivo.com Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
fe85a39d84
commit
d0fa875152
|
|
@ -89,7 +89,7 @@ static int led_bl_get_leds(struct device *dev,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
leds = devm_kzalloc(dev, sizeof(struct led_classdev *) * nb_leds,
|
||||
leds = devm_kcalloc(dev, nb_leds, sizeof(struct led_classdev *),
|
||||
GFP_KERNEL);
|
||||
if (!leds)
|
||||
return -ENOMEM;
|
||||
|
|
@ -137,7 +137,7 @@ static int led_bl_parse_levels(struct device *dev,
|
|||
unsigned int db;
|
||||
u32 *levels = NULL;
|
||||
|
||||
levels = devm_kzalloc(dev, sizeof(u32) * num_levels,
|
||||
levels = devm_kcalloc(dev, num_levels, sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
if (!levels)
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user