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/fsi | |
| 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/fsi')
| -rw-r--r-- | drivers/fsi/fsi-core.c | 4 | ||||
| -rw-r--r-- | drivers/fsi/fsi-master-aspeed.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-master-ast-cf.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-master-gpio.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-master-hub.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-master-i2cr.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-occ.c | 2 | ||||
| -rw-r--r-- | drivers/fsi/fsi-sbefifo.c | 4 | ||||
| -rw-r--r-- | drivers/fsi/fsi-scom.c | 2 |
9 files changed, 11 insertions, 11 deletions
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 83599a1c548b..abc3cf7f4ae4 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -211,7 +211,7 @@ static struct fsi_device *fsi_create_device(struct fsi_slave *slave) { struct fsi_device *dev; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) return NULL; @@ -1083,7 +1083,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) /* We can communicate with a slave; create the slave device and * register. */ - slave = kzalloc(sizeof(*slave), GFP_KERNEL); + slave = kzalloc_obj(*slave, GFP_KERNEL); if (!slave) return -ENOMEM; diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c index bff897f77fe5..2589f04c8d5b 100644 --- a/drivers/fsi/fsi-master-aspeed.c +++ b/drivers/fsi/fsi-master-aspeed.c @@ -546,7 +546,7 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev) return rc; } - aspeed = kzalloc(sizeof(*aspeed), GFP_KERNEL); + aspeed = kzalloc_obj(*aspeed, GFP_KERNEL); if (!aspeed) return -ENOMEM; diff --git a/drivers/fsi/fsi-master-ast-cf.c b/drivers/fsi/fsi-master-ast-cf.c index e67d7cd30fca..3b83ebeaf7c1 100644 --- a/drivers/fsi/fsi-master-ast-cf.c +++ b/drivers/fsi/fsi-master-ast-cf.c @@ -1220,7 +1220,7 @@ static int fsi_master_acf_probe(struct platform_device *pdev) uint32_t cf_mem_align; int rc; - master = kzalloc(sizeof(*master), GFP_KERNEL); + master = kzalloc_obj(*master, GFP_KERNEL); if (!master) return -ENOMEM; diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c index 69de0b5b9cbd..8c78ab1051d0 100644 --- a/drivers/fsi/fsi-master-gpio.c +++ b/drivers/fsi/fsi-master-gpio.c @@ -774,7 +774,7 @@ static int fsi_master_gpio_probe(struct platform_device *pdev) struct gpio_desc *gpio; int rc; - master = kzalloc(sizeof(*master), GFP_KERNEL); + master = kzalloc_obj(*master, GFP_KERNEL); if (!master) return -ENOMEM; diff --git a/drivers/fsi/fsi-master-hub.c b/drivers/fsi/fsi-master-hub.c index a84955bb23b1..6cee9f1a1d3a 100644 --- a/drivers/fsi/fsi-master-hub.c +++ b/drivers/fsi/fsi-master-hub.c @@ -215,7 +215,7 @@ static int hub_master_probe(struct fsi_device *fsi_dev) return rc; } - hub = kzalloc(sizeof(*hub), GFP_KERNEL); + hub = kzalloc_obj(*hub, GFP_KERNEL); if (!hub) { rc = -ENOMEM; goto err_release; diff --git a/drivers/fsi/fsi-master-i2cr.c b/drivers/fsi/fsi-master-i2cr.c index 40f1f4d231e5..055e850a8115 100644 --- a/drivers/fsi/fsi-master-i2cr.c +++ b/drivers/fsi/fsi-master-i2cr.c @@ -261,7 +261,7 @@ static int i2cr_probe(struct i2c_client *client) struct fsi_master_i2cr *i2cr; int ret; - i2cr = kzalloc(sizeof(*i2cr), GFP_KERNEL); + i2cr = kzalloc_obj(*i2cr, GFP_KERNEL); if (!i2cr) return -ENOMEM; diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c index e41ef12fa095..0ef1eccff91a 100644 --- a/drivers/fsi/fsi-occ.c +++ b/drivers/fsi/fsi-occ.c @@ -79,7 +79,7 @@ static DEFINE_IDA(occ_ida); static int occ_open(struct inode *inode, struct file *file) { - struct occ_client *client = kzalloc(sizeof(*client), GFP_KERNEL); + struct occ_client *client = kzalloc_obj(*client, GFP_KERNEL); struct miscdevice *mdev = file->private_data; struct occ *occ = to_occ(mdev); diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index 6ca5817910cd..5e62212f5ae4 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -792,7 +792,7 @@ static int sbefifo_user_open(struct inode *inode, struct file *file) struct sbefifo *sbefifo = container_of(inode->i_cdev, struct sbefifo, cdev); struct sbefifo_user *user; - user = kzalloc(sizeof(struct sbefifo_user), GFP_KERNEL); + user = kzalloc_obj(struct sbefifo_user, GFP_KERNEL); if (!user) return -ENOMEM; @@ -1033,7 +1033,7 @@ static int sbefifo_probe(struct fsi_device *fsi_dev) dev_dbg(dev, "Found sbefifo device\n"); - sbefifo = kzalloc(sizeof(*sbefifo), GFP_KERNEL); + sbefifo = kzalloc_obj(*sbefifo, GFP_KERNEL); if (!sbefifo) return -ENOMEM; diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c index 67cd45605fe4..bbdbc75ae192 100644 --- a/drivers/fsi/fsi-scom.c +++ b/drivers/fsi/fsi-scom.c @@ -533,7 +533,7 @@ static int scom_probe(struct fsi_device *fsi_dev) struct scom_device *scom; int rc, didx; - scom = kzalloc(sizeof(*scom), GFP_KERNEL); + scom = kzalloc_obj(*scom, GFP_KERNEL); if (!scom) return -ENOMEM; fsi_set_drvdata(fsi_dev, scom); |
