summaryrefslogtreecommitdiff
path: root/drivers/nfc/pn533
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/nfc/pn533
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/nfc/pn533')
-rw-r--r--drivers/nfc/pn533/pn533.c10
-rw-r--r--drivers/nfc/pn533/uart.c2
2 files changed, 6 insertions, 6 deletions
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 2b043a9f9533..8d62084c3e92 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -444,7 +444,7 @@ static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,
dev_dbg(dev->dev, "Sending command 0x%x\n", cmd_code);
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+ cmd = kzalloc_obj(*cmd, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
@@ -518,7 +518,7 @@ static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,
struct pn533_cmd *cmd;
int rc;
- cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
+ cmd = kzalloc_obj(*cmd, GFP_KERNEL);
if (!cmd)
return -ENOMEM;
@@ -2019,7 +2019,7 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
*next = 0;
}
- arg = kmalloc(sizeof(*arg), GFP_KERNEL);
+ arg = kmalloc_obj(*arg, GFP_KERNEL);
if (!arg) {
dev_kfree_skb(skb);
return -ENOMEM;
@@ -2266,7 +2266,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
goto error;
}
- arg = kmalloc(sizeof(*arg), GFP_KERNEL);
+ arg = kmalloc_obj(*arg, GFP_KERNEL);
if (!arg) {
rc = -ENOMEM;
goto error;
@@ -2744,7 +2744,7 @@ struct pn533 *pn53x_common_init(u32 device_type,
{
struct pn533 *priv;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/nfc/pn533/uart.c b/drivers/nfc/pn533/uart.c
index a081bce61c29..3355736e5e26 100644
--- a/drivers/nfc/pn533/uart.c
+++ b/drivers/nfc/pn533/uart.c
@@ -242,7 +242,7 @@ static int pn532_uart_probe(struct serdev_device *serdev)
int err;
err = -ENOMEM;
- pn532 = kzalloc(sizeof(*pn532), GFP_KERNEL);
+ pn532 = kzalloc_obj(*pn532, GFP_KERNEL);
if (!pn532)
goto err_exit;