diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/gpu/drm/rockchip | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from
scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to
avoid scalar types (which need careful case-by-case checking), and
instead replace kmalloc-family calls that allocate struct or union
object instances:
Single allocations: kmalloc(sizeof(TYPE), ...)
are replaced with: kmalloc_obj(TYPE, ...)
Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...)
are replaced with: kmalloc_objs(TYPE, COUNT, ...)
Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...)
are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...)
(where TYPE may also be *VAR)
The resulting allocations no longer return "void *", instead returning
"TYPE *".
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/gpu/drm/rockchip')
| -rw-r--r-- | drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/rockchip/rockchip_drm_gem.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 3 |
4 files changed, 6 insertions, 7 deletions
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c index 2f469d370021..43688d0322d7 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c @@ -36,7 +36,7 @@ rockchip_fb_create(struct drm_device *dev, struct drm_file *file, struct drm_afbc_framebuffer *afbc_fb; int ret; - afbc_fb = kzalloc(sizeof(*afbc_fb), GFP_KERNEL); + afbc_fb = kzalloc_obj(*afbc_fb, GFP_KERNEL); if (!afbc_fb) return ERR_PTR(-ENOMEM); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c index df9a8bff2e22..e6216773a6c4 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_gem.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_gem.c @@ -289,7 +289,7 @@ static struct rockchip_gem_object * size = round_up(size, PAGE_SIZE); - rk_obj = kzalloc(sizeof(*rk_obj), GFP_KERNEL); + rk_obj = kzalloc_obj(*rk_obj, GFP_KERNEL); if (!rk_obj) return ERR_PTR(-ENOMEM); @@ -434,7 +434,7 @@ struct sg_table *rockchip_gem_prime_get_sg_table(struct drm_gem_object *obj) if (rk_obj->pages) return drm_prime_pages_to_sg(obj->dev, rk_obj->pages, rk_obj->num_pages); - sgt = kzalloc(sizeof(*sgt), GFP_KERNEL); + sgt = kzalloc_obj(*sgt, GFP_KERNEL); if (!sgt) return ERR_PTR(-ENOMEM); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 1b466623b6c7..ab16765a407b 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -1658,8 +1658,8 @@ static void vop_crtc_destroy_state(struct drm_crtc *crtc, static void vop_crtc_reset(struct drm_crtc *crtc) { - struct rockchip_crtc_state *crtc_state = - kzalloc(sizeof(*crtc_state), GFP_KERNEL); + struct rockchip_crtc_state *crtc_state = kzalloc_obj(*crtc_state, + GFP_KERNEL); if (crtc->state) vop_crtc_destroy_state(crtc, crtc->state); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index ec3b4fde10db..b12970bcc588 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -2140,8 +2140,7 @@ static void vop2_crtc_destroy_state(struct drm_crtc *crtc, static void vop2_crtc_reset(struct drm_crtc *crtc) { - struct rockchip_crtc_state *vcstate = - kzalloc(sizeof(*vcstate), GFP_KERNEL); + struct rockchip_crtc_state *vcstate = kzalloc_obj(*vcstate, GFP_KERNEL); if (crtc->state) vop2_crtc_destroy_state(crtc, crtc->state); |
