Skip to content

Commit e12d3e1

Browse files
Henry Martinlag-linaro
authored andcommitted
backlight: pm8941: Add NULL check in wled_configure()
devm_kasprintf() returns NULL when memory allocation fails. Currently, wled_configure() does not check for this case, which results in a NULL pointer dereference. Add NULL check after devm_kasprintf() to prevent this issue. Fixes: f86b775 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") Signed-off-by: Henry Martin <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Reviewed-by: "Daniel Thompson (RISCstar)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent d32a0b5 commit e12d3e1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/video/backlight/qcom-wled.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,9 +1406,11 @@ static int wled_configure(struct wled *wled)
14061406
wled->ctrl_addr = be32_to_cpu(*prop_addr);
14071407

14081408
rc = of_property_read_string(dev->of_node, "label", &wled->name);
1409-
if (rc)
1409+
if (rc) {
14101410
wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node);
1411-
1411+
if (!wled->name)
1412+
return -ENOMEM;
1413+
}
14121414
switch (wled->version) {
14131415
case 3:
14141416
u32_opts = wled3_opts;

0 commit comments

Comments
 (0)