diff options
| author | Henry Martin <bsdhenrymartin@gmail.com> | 2025-04-01 17:16:47 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-06-19 15:32:04 +0200 |
| commit | 1be2000b703b02e149f8f2061054489f6c18c972 (patch) | |
| tree | 58f887c3dcc8cd5fa7f1a42494527c69253be875 /drivers/video | |
| parent | 48e0b54be49d25198ca3886ccfa5909eac0ef184 (diff) | |
| download | linux-1be2000b703b02e149f8f2061054489f6c18c972.tar.gz linux-1be2000b703b02e149f8f2061054489f6c18c972.tar.bz2 linux-1be2000b703b02e149f8f2061054489f6c18c972.zip | |
backlight: pm8941: Add NULL check in wled_configure()
[ Upstream commit e12d3e1624a02706cdd3628bbf5668827214fa33 ]
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: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org>
Link: https://lore.kernel.org/r/20250401091647.22784-1-bsdhenrymartin@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/video')
| -rw-r--r-- | drivers/video/backlight/qcom-wled.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index 10129095a4c1..b19e5f73de8b 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1406,9 +1406,11 @@ static int wled_configure(struct wled *wled) wled->ctrl_addr = be32_to_cpu(*prop_addr); rc = of_property_read_string(dev->of_node, "label", &wled->name); - if (rc) + if (rc) { wled->name = devm_kasprintf(dev, GFP_KERNEL, "%pOFn", dev->of_node); - + if (!wled->name) + return -ENOMEM; + } switch (wled->version) { case 3: u32_opts = wled3_opts; |
