Skip to contentSkip to conversation

drm/msm: Check for NULL return of kzalloc()

PATCH New QintaoShen 1 participant 1 message Mar 24, 2022

Subsystems (2)
lore
Share & tools
lore

QintaoShen

author
#0 lore raw

PATCH 1/1 drm/msm: Check for NULL return of kzalloc()

The allocation of kzalloc() may return NULL, which would bring a NULL pointer dereference bug.

To avoid this confusion, it is better to check the return value of kzalloc().

---
 drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c +2 -0
index 5d2ff67..d017deb 100644
@@ -176,6 +176,8 @@ void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len,
 	va_list va;
 
 	new_blk = kzalloc(sizeof(struct msm_disp_state_block), GFP_KERNEL);
+	if (!new_blk)
+		return ;
 
 	va_start(va, fmt);
 
Signature · 1 line
2.7.4