Message ID | 20240118094704.212641-1-chentao@kylinos.cn |
---|---|
State | New |
Headers | show |
Series | hwmon: (peci/cputemp) Add a null pointer check to the wled_configure | expand |
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index 10129095a4c1..a0b06839d778 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -1406,8 +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:
devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity. Signed-off-by: Kunwu Chan <chentao@kylinos.cn> --- drivers/video/backlight/qcom-wled.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)