1 | devm_kasprintf() return NULL if memory allocation fails. Currently, | 1 | The function wled_configure() uses devm_kasprintf() without checking for |
---|---|---|---|
2 | wled_configure() does not check for this case, leading to a possible NULL | 2 | allocation failures, which could lead to NULL pointer dereferences. |
3 | pointer dereference. | ||
4 | 3 | ||
5 | Add NULL check after devm_kasprintf() to prevent this issue. | 4 | Add proper error handling when devm_kasprintf() fails by: |
5 | - Returning -ENOMEM immediately | ||
6 | - Ensuring no resources are left allocated (none need cleanup in this case) | ||
6 | 7 | ||
7 | Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") | 8 | Fixes: f86b77583d88 ("backlight: pm8941: Convert to using %pOFn instead of device_node.name") |
8 | 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> | ||
9 | --- | 11 | --- |
12 | V2 -> V3: Fix commit message and verify proper error handling with | ||
13 | resource cleanup. | ||
10 | V1 -> V2: Fix commit message to use imperative mood and wrap lines to 75 | 14 | V1 -> V2: Fix commit message to use imperative mood and wrap lines to 75 |
11 | characters. | 15 | characters. |
12 | 16 | ||
13 | drivers/video/backlight/qcom-wled.c | 6 ++++-- | 17 | drivers/video/backlight/qcom-wled.c | 6 ++++-- |
14 | 1 file changed, 4 insertions(+), 2 deletions(-) | 18 | 1 file changed, 4 insertions(+), 2 deletions(-) |
... | ... | diff view generated by jsdifflib |