summaryrefslogtreecommitdiff
path: root/lib/pldmfw
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 /lib/pldmfw
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
lwn-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 'lib/pldmfw')
-rw-r--r--lib/pldmfw/pldmfw.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/pldmfw/pldmfw.c b/lib/pldmfw/pldmfw.c
index b45ceb725780..c1222c11f6a8 100644
--- a/lib/pldmfw/pldmfw.c
+++ b/lib/pldmfw/pldmfw.c
@@ -287,7 +287,7 @@ pldm_parse_desc_tlvs(struct pldmfw_priv *data, struct pldmfw_record *record, u8
if (err)
return err;
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
return -ENOMEM;
@@ -328,7 +328,7 @@ pldm_parse_one_record(struct pldmfw_priv *data,
int i;
/* Make a copy and insert it into the record list */
- record = kzalloc(sizeof(*record), GFP_KERNEL);
+ record = kzalloc_obj(*record, GFP_KERNEL);
if (!record)
return -ENOMEM;
@@ -465,7 +465,7 @@ static int pldm_parse_components(struct pldmfw_priv *data)
if (err)
return err;
- component = kzalloc(sizeof(*component), GFP_KERNEL);
+ component = kzalloc_obj(*component, GFP_KERNEL);
if (!component)
return -ENOMEM;
@@ -848,7 +848,7 @@ int pldmfw_flash_image(struct pldmfw *context, const struct firmware *fw)
struct pldmfw_priv *data;
int err;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;