1 | The function wled_configure() uses devm_kasprintf() without checking for | 1 | devm_kasprintf() returns NULL when memory allocation fails. Currently, |
---|---|---|---|
2 | allocation failures, which could lead to NULL pointer dereferences. | 2 | wled_configure() does not check for this case, which results in a NULL |
3 | pointer dereference. | ||
3 | 4 | ||
4 | Add proper error handling when devm_kasprintf() fails by: | 5 | Add NULL check after devm_kasprintf() to prevent this issue. |
5 | - Returning -ENOMEM immediately | ||
6 | - Ensuring no resources are left allocated (none need cleanup in this case) | ||
7 | 6 | ||
8 | Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") | 7 | Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") |
8 | Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
9 | Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> | 9 | Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com> |
10 | Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> | ||
11 | --- | 10 | --- |
12 | V2 -> V3: Fix commit message and verify proper error handling with | 11 | V2 -> V3: Correct commit meessage and confirm this patch has considered |
13 | resource cleanup. | 12 | resource cleanup to avoid any subsequent issues, ensuring that errors |
13 | are handled properly and no resources are left in an inconsistent | ||
14 | state. | ||
14 | V1 -> V2: Fix commit message to use imperative mood and wrap lines to 75 | 15 | V1 -> V2: Fix commit message to use imperative mood and wrap lines to 75 |
15 | characters. | 16 | characters. |
16 | 17 | ||
17 | drivers/video/backlight/qcom-wled.c | 6 ++++-- | 18 | drivers/video/backlight/qcom-wled.c | 6 ++++-- |
18 | 1 file changed, 4 insertions(+), 2 deletions(-) | 19 | 1 file changed, 4 insertions(+), 2 deletions(-) |
... | ... | diff view generated by jsdifflib |