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/remoteproc | |
| 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/remoteproc')
| -rw-r--r-- | drivers/remoteproc/qcom_common.c | 4 | ||||
| -rw-r--r-- | drivers/remoteproc/qcom_sysmon.c | 2 | ||||
| -rw-r--r-- | drivers/remoteproc/qcom_wcnss_iris.c | 2 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 10 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_coredump.c | 4 | ||||
| -rw-r--r-- | drivers/remoteproc/remoteproc_virtio.c | 2 | ||||
| -rw-r--r-- | drivers/remoteproc/stm32_rproc.c | 2 | ||||
| -rw-r--r-- | drivers/remoteproc/xlnx_r5_remoteproc.c | 9 |
8 files changed, 17 insertions, 18 deletions
diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c index 8c8688f99f0a..bb6038bf8bd4 100644 --- a/drivers/remoteproc/qcom_common.c +++ b/drivers/remoteproc/qcom_common.c @@ -370,7 +370,7 @@ static struct qcom_ssr_subsystem *qcom_ssr_get_subsys(const char *name) if (!strcmp(info->name, name)) goto out; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) { info = ERR_PTR(-ENOMEM); goto out; @@ -534,7 +534,7 @@ static int pdm_notify_prepare(struct rproc_subdev *subdev) struct auxiliary_device *adev; int ret; - adev = kzalloc(sizeof(*adev), GFP_KERNEL); + adev = kzalloc_obj(*adev, GFP_KERNEL); if (!adev) return -ENOMEM; diff --git a/drivers/remoteproc/qcom_sysmon.c b/drivers/remoteproc/qcom_sysmon.c index 660ac6fc4082..bbbe732fe767 100644 --- a/drivers/remoteproc/qcom_sysmon.c +++ b/drivers/remoteproc/qcom_sysmon.c @@ -628,7 +628,7 @@ struct qcom_sysmon *qcom_add_sysmon_subdev(struct rproc *rproc, struct qcom_sysmon *sysmon; int ret; - sysmon = kzalloc(sizeof(*sysmon), GFP_KERNEL); + sysmon = kzalloc_obj(*sysmon, GFP_KERNEL); if (!sysmon) return ERR_PTR(-ENOMEM); diff --git a/drivers/remoteproc/qcom_wcnss_iris.c b/drivers/remoteproc/qcom_wcnss_iris.c index 2b52b403eb3f..78cb8150f64b 100644 --- a/drivers/remoteproc/qcom_wcnss_iris.c +++ b/drivers/remoteproc/qcom_wcnss_iris.c @@ -125,7 +125,7 @@ struct qcom_iris *qcom_iris_probe(struct device *parent, bool *use_48mhz_xo) return ERR_PTR(-EINVAL); } - iris = kzalloc(sizeof(*iris), GFP_KERNEL); + iris = kzalloc_obj(*iris, GFP_KERNEL); if (!iris) { of_node_put(of_node); return ERR_PTR(-ENOMEM); diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index aada2780b343..bb5887a9d2ac 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -557,7 +557,7 @@ static int rproc_handle_trace(struct rproc *rproc, void *ptr, return -EINVAL; } - trace = kzalloc(sizeof(*trace), GFP_KERNEL); + trace = kzalloc_obj(*trace, GFP_KERNEL); if (!trace) return -ENOMEM; @@ -635,7 +635,7 @@ static int rproc_handle_devmem(struct rproc *rproc, void *ptr, return -EINVAL; } - mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); + mapping = kzalloc_obj(*mapping, GFP_KERNEL); if (!mapping) return -ENOMEM; @@ -727,7 +727,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, * physical address in this case. */ if (mem->da != FW_RSC_ADDR_ANY && rproc->domain) { - mapping = kzalloc(sizeof(*mapping), GFP_KERNEL); + mapping = kzalloc_obj(*mapping, GFP_KERNEL); if (!mapping) { ret = -ENOMEM; goto dma_free; @@ -917,7 +917,7 @@ rproc_mem_entry_init(struct device *dev, struct rproc_mem_entry *mem; va_list args; - mem = kzalloc(sizeof(*mem), GFP_KERNEL); + mem = kzalloc_obj(*mem, GFP_KERNEL); if (!mem) return mem; @@ -960,7 +960,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len, struct rproc_mem_entry *mem; va_list args; - mem = kzalloc(sizeof(*mem), GFP_KERNEL); + mem = kzalloc_obj(*mem, GFP_KERNEL); if (!mem) return mem; diff --git a/drivers/remoteproc/remoteproc_coredump.c b/drivers/remoteproc/remoteproc_coredump.c index 6ede8c0c93ad..f925c8e775a5 100644 --- a/drivers/remoteproc/remoteproc_coredump.c +++ b/drivers/remoteproc/remoteproc_coredump.c @@ -49,7 +49,7 @@ int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size) { struct rproc_dump_segment *segment; - segment = kzalloc(sizeof(*segment), GFP_KERNEL); + segment = kzalloc_obj(*segment, GFP_KERNEL); if (!segment) return -ENOMEM; @@ -86,7 +86,7 @@ int rproc_coredump_add_custom_segment(struct rproc *rproc, { struct rproc_dump_segment *segment; - segment = kzalloc(sizeof(*segment), GFP_KERNEL); + segment = kzalloc_obj(*segment, GFP_KERNEL); if (!segment) return -ENOMEM; diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index c5d46a878149..92c7c0b0ad65 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -430,7 +430,7 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) } /* Allocate virtio device */ - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); + vdev = kzalloc_obj(*vdev, GFP_KERNEL); if (!vdev) { ret = -ENOMEM; goto out; diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index c28679d3b43c..6185343a6d3f 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -164,7 +164,7 @@ static int stm32_rproc_of_memory_translations(struct platform_device *pdev, p_mems = devm_kcalloc(dev, cnt, sizeof(*p_mems), GFP_KERNEL); if (!p_mems) return -ENOMEM; - mem_range = kcalloc(cnt, sizeof(*mem_range), GFP_KERNEL); + mem_range = kzalloc_objs(*mem_range, cnt, GFP_KERNEL); if (!mem_range) return -ENOMEM; diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c index bd619a6c42aa..a8b13fb50992 100644 --- a/drivers/remoteproc/xlnx_r5_remoteproc.c +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c @@ -265,7 +265,7 @@ static struct mbox_info *zynqmp_r5_setup_mbox(struct device *cdev) struct mbox_client *mbox_cl; struct mbox_info *ipi; - ipi = kzalloc(sizeof(*ipi), GFP_KERNEL); + ipi = kzalloc_obj(*ipi, GFP_KERNEL); if (!ipi) return NULL; @@ -1337,12 +1337,11 @@ static int zynqmp_r5_cluster_init(struct zynqmp_r5_cluster *cluster) core_count = 1; } - child_devs = kcalloc(core_count, sizeof(struct device *), GFP_KERNEL); + child_devs = kzalloc_objs(struct device *, core_count, GFP_KERNEL); if (!child_devs) return -ENOMEM; - r5_cores = kcalloc(core_count, - sizeof(struct zynqmp_r5_core *), GFP_KERNEL); + r5_cores = kzalloc_objs(struct zynqmp_r5_core *, core_count, GFP_KERNEL); if (!r5_cores) { kfree(child_devs); return -ENOMEM; @@ -1503,7 +1502,7 @@ static int zynqmp_r5_remoteproc_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret; - cluster = kzalloc(sizeof(*cluster), GFP_KERNEL); + cluster = kzalloc_obj(*cluster, GFP_KERNEL); if (!cluster) return -ENOMEM; |
