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/display/drm_dp_tunnel.c | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.zip | |
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/display/drm_dp_tunnel.c')
| -rw-r--r-- | drivers/gpu/drm/display/drm_dp_tunnel.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpu/drm/display/drm_dp_tunnel.c b/drivers/gpu/drm/display/drm_dp_tunnel.c index 43f13a7c79b9..005ee68e6cd4 100644 --- a/drivers/gpu/drm/display/drm_dp_tunnel.c +++ b/drivers/gpu/drm/display/drm_dp_tunnel.c @@ -476,7 +476,7 @@ create_tunnel(struct drm_dp_tunnel_mgr *mgr, u8 drv_group_id = tunnel_reg_drv_group_id(regs); struct drm_dp_tunnel *tunnel; - tunnel = kzalloc(sizeof(*tunnel), GFP_KERNEL); + tunnel = kzalloc_obj(*tunnel, GFP_KERNEL); if (!tunnel) return NULL; @@ -1387,7 +1387,7 @@ add_tunnel_state(struct drm_dp_tunnel_group_state *group_state, "Adding state for tunnel %p to group state %p\n", tunnel, group_state); - tunnel_state = kzalloc(sizeof(*tunnel_state), GFP_KERNEL); + tunnel_state = kzalloc_obj(*tunnel_state, GFP_KERNEL); if (!tunnel_state) return NULL; @@ -1458,7 +1458,7 @@ tunnel_group_duplicate_state(struct drm_private_obj *obj) struct drm_dp_tunnel_group_state *group_state; struct drm_dp_tunnel_state *tunnel_state; - group_state = kzalloc(sizeof(*group_state), GFP_KERNEL); + group_state = kzalloc_obj(*group_state, GFP_KERNEL); if (!group_state) return NULL; @@ -1583,7 +1583,7 @@ static bool init_group(struct drm_dp_tunnel_mgr *mgr, struct drm_dp_tunnel_group { struct drm_dp_tunnel_group_state *group_state; - group_state = kzalloc(sizeof(*group_state), GFP_KERNEL); + group_state = kzalloc_obj(*group_state, GFP_KERNEL); if (!group_state) return false; @@ -1644,7 +1644,7 @@ static int resize_bw_array(struct drm_dp_tunnel_state *tunnel_state, if (old_mask == new_mask) return 0; - new_bws = kcalloc(hweight32(new_mask), sizeof(*new_bws), GFP_KERNEL); + new_bws = kzalloc_objs(*new_bws, hweight32(new_mask), GFP_KERNEL); if (!new_bws) return -ENOMEM; @@ -1906,14 +1906,14 @@ drm_dp_tunnel_mgr_create(struct drm_device *dev, int max_group_count) struct drm_dp_tunnel_mgr *mgr; int i; - mgr = kzalloc(sizeof(*mgr), GFP_KERNEL); + mgr = kzalloc_obj(*mgr, GFP_KERNEL); if (!mgr) return ERR_PTR(-ENOMEM); mgr->dev = dev; init_waitqueue_head(&mgr->bw_req_queue); - mgr->groups = kcalloc(max_group_count, sizeof(*mgr->groups), GFP_KERNEL); + mgr->groups = kzalloc_objs(*mgr->groups, max_group_count, GFP_KERNEL); if (!mgr->groups) { kfree(mgr); |
