drm/mediatek: Initialize pointer to avoid undefined behavior
Subsystems (3)
PATCH v2 1/1 drm/mediatek: Initialize pointer to avoid undefined behavior
Initialize the next pointer with NULL as the function mtk_drm_of_get_ddp_ep_cid might return early without assigning a value to next.
Dereferencing an uninitialized pointer can lead to undefined behavior, as it might point to an invalid memory location.
Coverity CID: 1601557
---
Coverity Message:
CID 1601557: (#1 of 1): Uninitialized pointer read (UNINIT)
3. uninit_use: Using uninitialized value next.
Coverity Link:
https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601557
---
Changes in v2:
- Updated the patch subject and summary log
- Link to v1: https://lore.kernel.org/r/[email protected]
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +1 -1
@@ -900,7 +900,7 @@ static int mtk_drm_of_ddp_path_build_one(struct device *dev, enum mtk_crtc_pathconst unsigned int **out_path, unsigned int *out_path_len) { - struct device_node *next, *prev, *vdo = dev->parent->of_node; + struct device_node *next = NULL, *prev, *vdo = dev->parent->of_node;unsigned int temp_path[DDP_COMPONENT_DRM_ID_MAX ] = {0 };unsigned int *final_ddp_path;unsigned short int idx =0 ;
---
base-commit: 6d59cab07b8d74d0f0422b750038123334f6ecc2
change-id: 20241111-uninitializedpointer1601557-9803b725b6bd
Best regards,
Signature · 1 line
Karan Sanghavi <[email protected]>