Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/msm: Add error handling for krealloc in metadata setup

Function msm_ioctl_gem_info_set_metadata() now checks for krealloc
failure and returns -ENOMEM, avoiding potential NULL pointer dereference.
Explicitly avoids __GFP_NOFAIL due to deadlock risks and allocation constraints.

Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
Patchwork: https://patchwork.freedesktop.org/patch/661235/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>

authored by

Yuan Chen and committed by
Rob Clark
1c8c3540 024bd19b

+8 -1
+8 -1
drivers/gpu/drm/msm/msm_drv.c
··· 555 555 u32 metadata_size) 556 556 { 557 557 struct msm_gem_object *msm_obj = to_msm_bo(obj); 558 + void *new_metadata; 558 559 void *buf; 559 560 int ret; 560 561 ··· 573 572 if (ret) 574 573 goto out; 575 574 576 - msm_obj->metadata = 575 + new_metadata = 577 576 krealloc(msm_obj->metadata, metadata_size, GFP_KERNEL); 577 + if (!new_metadata) { 578 + ret = -ENOMEM; 579 + goto out; 580 + } 581 + 582 + msm_obj->metadata = new_metadata; 578 583 msm_obj->metadata_size = metadata_size; 579 584 memcpy(msm_obj->metadata, buf, metadata_size); 580 585