summaryrefslogtreecommitdiff
path: root/drivers/soc/fsl/dpio
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/soc/fsl/dpio
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 'drivers/soc/fsl/dpio')
-rw-r--r--drivers/soc/fsl/dpio/dpio-service.c6
-rw-r--r--drivers/soc/fsl/dpio/qbman-portal.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index 0b60ed16297c..2a73d4e846ff 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -133,7 +133,7 @@ static void dpaa2_io_dim_work(struct work_struct *w)
struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc,
struct device *dev)
{
- struct dpaa2_io *obj = kmalloc(sizeof(*obj), GFP_KERNEL);
+ struct dpaa2_io *obj = kmalloc_obj(*obj, GFP_KERNEL);
u32 qman_256_cycles_per_ns;
if (!obj)
@@ -523,7 +523,7 @@ int dpaa2_io_service_enqueue_multiple_desc_fq(struct dpaa2_io *d,
struct qbman_eq_desc *ed;
int i, ret;
- ed = kcalloc(32, sizeof(struct qbman_eq_desc), GFP_KERNEL);
+ ed = kzalloc_objs(struct qbman_eq_desc, 32, GFP_KERNEL);
if (!ed)
return -ENOMEM;
@@ -658,7 +658,7 @@ struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
if (!max_frames || (max_frames > 32))
return NULL;
- ret = kmalloc(sizeof(*ret), GFP_KERNEL);
+ ret = kmalloc_obj(*ret, GFP_KERNEL);
if (!ret)
return NULL;
diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c
index 0a3fb6c115f4..b6adc87f473a 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -246,7 +246,7 @@ static inline u8 qm_cyc_diff(u8 ringsize, u8 first, u8 last)
*/
struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
{
- struct qbman_swp *p = kzalloc(sizeof(*p), GFP_KERNEL);
+ struct qbman_swp *p = kzalloc_obj(*p, GFP_KERNEL);
u32 reg;
u32 mask_size;
u32 eqcr_pi;