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/hwtracing/coresight | |
| 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/hwtracing/coresight')
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-catu.c | 2 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-core.c | 6 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-cti-platform.c | 2 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-etm-perf.c | 2 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-syscfg.c | 4 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-tmc-etr.c | 15 | ||||
| -rw-r--r-- | drivers/hwtracing/coresight/coresight-trbe.c | 2 |
7 files changed, 16 insertions, 17 deletions
diff --git a/drivers/hwtracing/coresight/coresight-catu.c b/drivers/hwtracing/coresight/coresight-catu.c index 69b36bae97ab..4123d4e16bbe 100644 --- a/drivers/hwtracing/coresight/coresight-catu.c +++ b/drivers/hwtracing/coresight/coresight-catu.c @@ -337,7 +337,7 @@ static int catu_alloc_etr_buf(struct tmc_drvdata *tmc_drvdata, csdev = tmc_etr_get_catu_device(tmc_drvdata); if (!csdev) return -ENODEV; - catu_buf = kzalloc(sizeof(*catu_buf), GFP_KERNEL); + catu_buf = kzalloc_obj(*catu_buf, GFP_KERNEL); if (!catu_buf) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index c660cf8adb1c..b03d228f6bf7 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -821,7 +821,7 @@ out: if (ret) return ret; - node = kzalloc(sizeof(struct coresight_node), GFP_KERNEL); + node = kzalloc_obj(struct coresight_node, GFP_KERNEL); if (!node) return -ENOMEM; @@ -840,7 +840,7 @@ struct coresight_path *coresight_build_path(struct coresight_device *source, if (!sink) return ERR_PTR(-EINVAL); - path = kzalloc(sizeof(struct coresight_path), GFP_KERNEL); + path = kzalloc_obj(struct coresight_path, GFP_KERNEL); if (!path) return ERR_PTR(-ENOMEM); @@ -1327,7 +1327,7 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) struct coresight_device *csdev; bool registered = false; - csdev = kzalloc(sizeof(*csdev), GFP_KERNEL); + csdev = kzalloc_obj(*csdev, GFP_KERNEL); if (!csdev) { ret = -ENOMEM; goto err_out; diff --git a/drivers/hwtracing/coresight/coresight-cti-platform.c b/drivers/hwtracing/coresight/coresight-cti-platform.c index d0ae10bf6128..ecb0bdc2c3e6 100644 --- a/drivers/hwtracing/coresight/coresight-cti-platform.c +++ b/drivers/hwtracing/coresight/coresight-cti-platform.c @@ -325,7 +325,7 @@ static int cti_plat_process_filter_sigs(struct cti_drvdata *drvdata, if (nr_filter_sigs > drvdata->config.nr_trig_max) return -EINVAL; - tg = kzalloc(sizeof(*tg), GFP_KERNEL); + tg = kzalloc_obj(*tg, GFP_KERNEL); if (!tg) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index 3c8a6f795094..01d4c422fed9 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -260,7 +260,7 @@ static void *alloc_event_data(int cpu) struct etm_event_data *event_data; /* First get memory for the session's data */ - event_data = kzalloc(sizeof(struct etm_event_data), GFP_KERNEL); + event_data = kzalloc_obj(struct etm_event_data, GFP_KERNEL); if (!event_data) return NULL; diff --git a/drivers/hwtracing/coresight/coresight-syscfg.c b/drivers/hwtracing/coresight/coresight-syscfg.c index 6836b05986e8..de2f6947f521 100644 --- a/drivers/hwtracing/coresight/coresight-syscfg.c +++ b/drivers/hwtracing/coresight/coresight-syscfg.c @@ -756,7 +756,7 @@ static int cscfg_list_add_csdev(struct coresight_device *csdev, struct cscfg_registered_csdev *csdev_item; /* allocate the list entry structure */ - csdev_item = kzalloc(sizeof(struct cscfg_registered_csdev), GFP_KERNEL); + csdev_item = kzalloc_obj(struct cscfg_registered_csdev, GFP_KERNEL); if (!csdev_item) return -ENOMEM; @@ -1190,7 +1190,7 @@ static int cscfg_create_device(void) goto create_dev_exit_unlock; } - cscfg_mgr = kzalloc(sizeof(struct cscfg_manager), GFP_KERNEL); + cscfg_mgr = kzalloc_obj(struct cscfg_manager, GFP_KERNEL); if (!cscfg_mgr) goto create_dev_exit_unlock; diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index cee82e52c4ea..7aca22d6e335 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -204,12 +204,11 @@ static int tmc_pages_alloc(struct tmc_pages *tmc_pages, struct device *real_dev = dev->parent; nr_pages = tmc_pages->nr_pages; - tmc_pages->daddrs = kcalloc(nr_pages, sizeof(*tmc_pages->daddrs), + tmc_pages->daddrs = kzalloc_objs(*tmc_pages->daddrs, nr_pages, GFP_KERNEL); if (!tmc_pages->daddrs) return -ENOMEM; - tmc_pages->pages = kcalloc(nr_pages, sizeof(*tmc_pages->pages), - GFP_KERNEL); + tmc_pages->pages = kzalloc_objs(*tmc_pages->pages, nr_pages, GFP_KERNEL); if (!tmc_pages->pages) { kfree(tmc_pages->daddrs); tmc_pages->daddrs = NULL; @@ -332,7 +331,7 @@ struct tmc_sg_table *tmc_alloc_sg_table(struct device *dev, long rc; struct tmc_sg_table *sg_table; - sg_table = kzalloc(sizeof(*sg_table), GFP_KERNEL); + sg_table = kzalloc_obj(*sg_table, GFP_KERNEL); if (!sg_table) return ERR_PTR(-ENOMEM); sg_table->data_pages.nr_pages = nr_dpages; @@ -575,7 +574,7 @@ tmc_init_etr_sg_table(struct device *dev, int node, struct tmc_sg_table *sg_table; struct etr_sg_table *etr_table; - etr_table = kzalloc(sizeof(*etr_table), GFP_KERNEL); + etr_table = kzalloc_obj(*etr_table, GFP_KERNEL); if (!etr_table) return ERR_PTR(-ENOMEM); nr_entries = tmc_etr_sg_table_entries(nr_dpages); @@ -612,7 +611,7 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata, if (pages) return -EINVAL; - flat_buf = kzalloc(sizeof(*flat_buf), GFP_KERNEL); + flat_buf = kzalloc_obj(*flat_buf, GFP_KERNEL); if (!flat_buf) return -ENOMEM; @@ -710,7 +709,7 @@ static int tmc_etr_alloc_resrv_buf(struct tmc_drvdata *drvdata, if (pages) return -EINVAL; - resrv_buf = kzalloc(sizeof(*resrv_buf), GFP_KERNEL); + resrv_buf = kzalloc_obj(*resrv_buf, GFP_KERNEL); if (!resrv_buf) return -ENOMEM; @@ -942,7 +941,7 @@ static struct etr_buf *tmc_alloc_etr_buf(struct tmc_drvdata *drvdata, struct device *dev = &drvdata->csdev->dev; get_etr_buf_hw(dev, &buf_hw); - etr_buf = kzalloc(sizeof(*etr_buf), GFP_KERNEL); + etr_buf = kzalloc_obj(*etr_buf, GFP_KERNEL); if (!etr_buf) return ERR_PTR(-ENOMEM); diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 474861903f6c..257dd5689c81 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -751,7 +751,7 @@ static void *arm_trbe_alloc_buffer(struct coresight_device *csdev, if (!buf) return NULL; - pglist = kcalloc(nr_pages, sizeof(*pglist), GFP_KERNEL); + pglist = kzalloc_objs(*pglist, nr_pages, GFP_KERNEL); if (!pglist) { kfree(buf); return NULL; |
