summaryrefslogtreecommitdiff
path: root/sound/xen
diff options
context:
space:
mode:
authorKees Cook2026-02-20 23:49:23 -0800
committerKees Cook2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /sound/xen
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (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 'sound/xen')
-rw-r--r--sound/xen/xen_snd_front_alsa.c4
-rw-r--r--sound/xen/xen_snd_front_evtchnl.c5
2 files changed, 4 insertions, 5 deletions
diff --git a/sound/xen/xen_snd_front_alsa.c b/sound/xen/xen_snd_front_alsa.c
index b229eb6f7057..379a4a1cb911 100644
--- a/sound/xen/xen_snd_front_alsa.c
+++ b/sound/xen/xen_snd_front_alsa.c
@@ -442,8 +442,8 @@ static int shbuf_setup_backstore(struct xen_snd_front_pcm_stream_info *stream,
stream->buffer_sz = buffer_sz;
stream->num_pages = DIV_ROUND_UP(stream->buffer_sz, PAGE_SIZE);
- stream->pages = kcalloc(stream->num_pages, sizeof(struct page *),
- GFP_KERNEL);
+ stream->pages = kzalloc_objs(struct page *, stream->num_pages,
+ GFP_KERNEL);
if (!stream->pages)
return -ENOMEM;
diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_evtchnl.c
index 2fbed8e4a490..8a8807cbc80c 100644
--- a/sound/xen/xen_snd_front_evtchnl.c
+++ b/sound/xen/xen_snd_front_evtchnl.c
@@ -267,9 +267,8 @@ int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info,
int d, ret = 0;
front_info->evt_pairs =
- kcalloc(num_streams,
- sizeof(struct xen_snd_front_evtchnl_pair),
- GFP_KERNEL);
+ kzalloc_objs(struct xen_snd_front_evtchnl_pair,
+ num_streams, GFP_KERNEL);
if (!front_info->evt_pairs)
return -ENOMEM;