diff options
| author | Kees Cook | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/i2c | |
| 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/i2c')
31 files changed, 46 insertions, 48 deletions
diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c index e7720ea4045e..b9a86eb10cc2 100644 --- a/drivers/i2c/busses/i2c-cp2615.c +++ b/drivers/i2c/busses/i2c-cp2615.c @@ -124,7 +124,7 @@ static int cp2615_check_status(enum cp2615_i2c_status status) static int cp2615_i2c_send(struct usb_interface *usbif, struct cp2615_i2c_transfer *i2c_w) { - struct cp2615_iop_msg *msg = kzalloc(sizeof(*msg), GFP_KERNEL); + struct cp2615_iop_msg *msg = kzalloc_obj(*msg, GFP_KERNEL); struct usb_device *usbdev = interface_to_usbdev(usbif); int res = cp2615_init_i2c_msg(msg, i2c_w); @@ -143,7 +143,7 @@ cp2615_i2c_recv(struct usb_interface *usbif, unsigned char tag, void *buf) struct cp2615_i2c_transfer_result *i2c_r; int res; - msg = kzalloc(sizeof(*msg), GFP_KERNEL); + msg = kzalloc_obj(*msg, GFP_KERNEL); if (!msg) return -ENOMEM; @@ -171,7 +171,7 @@ cp2615_i2c_recv(struct usb_interface *usbif, unsigned char tag, void *buf) /* Checks if the IOP is functional by querying the part's ID */ static int cp2615_check_iop(struct usb_interface *usbif) { - struct cp2615_iop_msg *msg = kzalloc(sizeof(*msg), GFP_KERNEL); + struct cp2615_iop_msg *msg = kzalloc_obj(*msg, GFP_KERNEL); struct cp2615_iop_accessory_info *info = (struct cp2615_iop_accessory_info *)&msg->data; struct usb_device *usbdev = interface_to_usbdev(usbif); int res = cp2615_init_iop_msg(msg, iop_GetAccessoryInfo, NULL, 0); diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c index 260e1643c2cc..dbe90974167a 100644 --- a/drivers/i2c/busses/i2c-cpm.c +++ b/drivers/i2c/busses/i2c-cpm.c @@ -636,7 +636,7 @@ static int cpm_i2c_probe(struct platform_device *ofdev) struct cpm_i2c *cpm; const u32 *data; - cpm = kzalloc(sizeof(struct cpm_i2c), GFP_KERNEL); + cpm = kzalloc_obj(struct cpm_i2c, GFP_KERNEL); if (!cpm) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-designware-amdpsp.c b/drivers/i2c/busses/i2c-designware-amdpsp.c index 404571ad61a8..c4d3b0ee6f4d 100644 --- a/drivers/i2c/busses/i2c-designware-amdpsp.c +++ b/drivers/i2c/busses/i2c-designware-amdpsp.c @@ -93,7 +93,7 @@ static int psp_send_i2c_req(enum psp_i2c_req_type i2c_req_type) int status, ret; /* Allocate command-response buffer */ - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = kzalloc_obj(*req, GFP_KERNEL); if (!req) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c index c02459405b26..ba0a2e03f490 100644 --- a/drivers/i2c/busses/i2c-diolan-u2c.c +++ b/drivers/i2c/busses/i2c-diolan-u2c.c @@ -445,7 +445,7 @@ static int diolan_u2c_probe(struct usb_interface *interface, return -ENODEV; /* allocate memory for our device state and initialize it */ - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (dev == NULL) { ret = -ENOMEM; goto error; diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c index 27ea3c130a16..65ac713e8a84 100644 --- a/drivers/i2c/busses/i2c-eg20t.c +++ b/drivers/i2c/busses/i2c-eg20t.c @@ -720,7 +720,7 @@ static int pch_i2c_probe(struct pci_dev *pdev, pch_pci_dbg(pdev, "Entered.\n"); - adap_info = kzalloc((sizeof(struct adapter_info)), GFP_KERNEL); + adap_info = kzalloc_obj(struct adapter_info, GFP_KERNEL); if (adap_info == NULL) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index 3a7e577e6eac..77b4129e1ee6 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -707,7 +707,7 @@ static int fsi_i2c_probe(struct fsi_device *fsi_dev) if (!of_device_is_available(np)) continue; - port = kzalloc(sizeof(*port), GFP_KERNEL); + port = kzalloc_obj(*port, GFP_KERNEL); if (!port) { of_node_put(np); break; diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c index 78c5845e0877..ddea5847f0c5 100644 --- a/drivers/i2c/busses/i2c-highlander.c +++ b/drivers/i2c/busses/i2c-highlander.c @@ -365,7 +365,7 @@ static int highlander_i2c_probe(struct platform_device *pdev) return -ENODEV; } - dev = kzalloc(sizeof(struct highlander_i2c_dev), GFP_KERNEL); + dev = kzalloc_obj(struct highlander_i2c_dev, GFP_KERNEL); if (unlikely(!dev)) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c index 6bf45d752ff9..ca2534bba932 100644 --- a/drivers/i2c/busses/i2c-ibm_iic.c +++ b/drivers/i2c/busses/i2c-ibm_iic.c @@ -687,7 +687,7 @@ static int iic_probe(struct platform_device *ofdev) const u32 *freq; int ret; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c index ce5ca5b90b39..f5c1d2191c98 100644 --- a/drivers/i2c/busses/i2c-iop3xx.c +++ b/drivers/i2c/busses/i2c-iop3xx.c @@ -415,13 +415,13 @@ iop3xx_i2c_probe(struct platform_device *pdev) struct i2c_adapter *new_adapter; struct i2c_algo_iop3xx_data *adapter_data; - new_adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); + new_adapter = kzalloc_obj(struct i2c_adapter, GFP_KERNEL); if (!new_adapter) { ret = -ENOMEM; goto out; } - adapter_data = kzalloc(sizeof(struct i2c_algo_iop3xx_data), GFP_KERNEL); + adapter_data = kzalloc_obj(struct i2c_algo_iop3xx_data, GFP_KERNEL); if (!adapter_data) { ret = -ENOMEM; goto free_adapter; diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index d58a308582e4..b673206313fc 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c @@ -359,7 +359,7 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id) int res1, res2; /* we support 2 SMBus adapters */ - smbuses = kcalloc(2, sizeof(struct nforce2_smbus), GFP_KERNEL); + smbuses = kzalloc_objs(struct nforce2_smbus, 2, GFP_KERNEL); if (!smbuses) return -ENOMEM; pci_set_drvdata(dev, smbuses); diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c index 3249bbd5eb43..5ae1c7f8b9b5 100644 --- a/drivers/i2c/busses/i2c-parport.c +++ b/drivers/i2c/busses/i2c-parport.c @@ -288,7 +288,7 @@ static void i2c_parport_attach(struct parport *port) return; } - adapter = kzalloc(sizeof(struct i2c_par), GFP_KERNEL); + adapter = kzalloc_obj(struct i2c_par, GFP_KERNEL); if (!adapter) return; memset(&i2c_parport_cb, 0, sizeof(i2c_parport_cb)); diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index ac3bb550303f..e159a9aed41f 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -919,7 +919,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, struct i2c_piix4_adapdata *adapdata; int retval; - adap = kzalloc(sizeof(*adap), GFP_KERNEL); + adap = kzalloc_obj(*adap, GFP_KERNEL); if (adap == NULL) { release_region(smba, SMBIOSIZE); return -ENOMEM; @@ -930,7 +930,7 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, adap->algo = sb800_main ? &piix4_smbus_algorithm_sb800 : &smbus_algorithm; - adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL); + adapdata = kzalloc_obj(*adapdata, GFP_KERNEL); if (adapdata == NULL) { kfree(adap); release_region(smba, SMBIOSIZE); diff --git a/drivers/i2c/busses/i2c-pxa-pci.c b/drivers/i2c/busses/i2c-pxa-pci.c index af2094720a4d..c80a054fc4e9 100644 --- a/drivers/i2c/busses/i2c-pxa-pci.c +++ b/drivers/i2c/busses/i2c-pxa-pci.c @@ -112,7 +112,7 @@ static int ce4100_i2c_probe(struct pci_dev *dev, dev_err(&dev->dev, "Missing device tree node.\n"); return -EINVAL; } - sds = kzalloc(sizeof(*sds), GFP_KERNEL); + sds = kzalloc_obj(*sds, GFP_KERNEL); if (!sds) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c index ae609bdd2ec4..9958920f635e 100644 --- a/drivers/i2c/busses/i2c-qcom-geni.c +++ b/drivers/i2c/busses/i2c-qcom-geni.c @@ -799,7 +799,8 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], i if (gi2c->is_tx_multi_desc_xfer) { tx_multi_xfer->dma_buf = kcalloc(num, sizeof(void *), GFP_KERNEL); - tx_multi_xfer->dma_addr = kcalloc(num, sizeof(dma_addr_t), GFP_KERNEL); + tx_multi_xfer->dma_addr = kzalloc_objs(dma_addr_t, num, + GFP_KERNEL); if (!tx_multi_xfer->dma_buf || !tx_multi_xfer->dma_addr) { ret = -ENOMEM; goto err; diff --git a/drivers/i2c/busses/i2c-scmi.c b/drivers/i2c/busses/i2c-scmi.c index 10a5146b3aa5..c10ad0677949 100644 --- a/drivers/i2c/busses/i2c-scmi.c +++ b/drivers/i2c/busses/i2c-scmi.c @@ -359,7 +359,7 @@ static int smbus_cmi_probe(struct platform_device *device) struct acpi_smbus_cmi *smbus_cmi; int ret; - smbus_cmi = kzalloc(sizeof(struct acpi_smbus_cmi), GFP_KERNEL); + smbus_cmi = kzalloc_obj(struct acpi_smbus_cmi, GFP_KERNEL); if (!smbus_cmi) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c index 43f33988b98f..dcdf56398f70 100644 --- a/drivers/i2c/busses/i2c-sh7760.c +++ b/drivers/i2c/busses/i2c-sh7760.c @@ -443,7 +443,7 @@ static int sh7760_i2c_probe(struct platform_device *pdev) goto out0; } - id = kzalloc(sizeof(*id), GFP_KERNEL); + id = kzalloc_obj(*id, GFP_KERNEL); if (!id) { ret = -ENOMEM; goto out0; diff --git a/drivers/i2c/busses/i2c-simtec.c b/drivers/i2c/busses/i2c-simtec.c index d90606048611..9572357cc177 100644 --- a/drivers/i2c/busses/i2c-simtec.c +++ b/drivers/i2c/busses/i2c-simtec.c @@ -64,7 +64,7 @@ static int simtec_i2c_probe(struct platform_device *dev) int size; int ret; - pd = kzalloc(sizeof(struct simtec_i2c_data), GFP_KERNEL); + pd = kzalloc_obj(struct simtec_i2c_data, GFP_KERNEL); if (pd == NULL) return -ENOMEM; diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index dc69ed934ec8..e2388862f29e 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -544,7 +544,7 @@ static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev, if (((sdadel >= sdadel_min) && (sdadel <= sdadel_max)) && (p != p_prev)) { - v = kmalloc(sizeof(*v), GFP_KERNEL); + v = kmalloc_obj(*v, GFP_KERNEL); if (!v) { ret = -ENOMEM; goto exit; diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c index cb97f72291bc..e8a89b7d2174 100644 --- a/drivers/i2c/busses/i2c-taos-evm.c +++ b/drivers/i2c/busses/i2c-taos-evm.c @@ -203,7 +203,7 @@ static int taos_connect(struct serio *serio, struct serio_driver *drv) char *name; int err; - taos = kzalloc(sizeof(struct taos_data), GFP_KERNEL); + taos = kzalloc_obj(struct taos_data, GFP_KERNEL); if (!taos) { err = -ENOMEM; goto exit; diff --git a/drivers/i2c/busses/i2c-tiny-usb.c b/drivers/i2c/busses/i2c-tiny-usb.c index 57dfe5f1a7d9..ab021042901b 100644 --- a/drivers/i2c/busses/i2c-tiny-usb.c +++ b/drivers/i2c/busses/i2c-tiny-usb.c @@ -55,7 +55,7 @@ static int usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) struct i2c_msg *pmsg; int i, ret; - pstatus = kmalloc(sizeof(*pstatus), GFP_KERNEL); + pstatus = kmalloc_obj(*pstatus, GFP_KERNEL); if (!pstatus) return -ENOMEM; @@ -123,7 +123,7 @@ static u32 usb_func(struct i2c_adapter *adapter) __le32 *pfunc; u32 ret; - pfunc = kmalloc(sizeof(*pfunc), GFP_KERNEL); + pfunc = kmalloc_obj(*pfunc, GFP_KERNEL); /* get functionality from adapter */ if (!pfunc || usb_read(adapter, CMD_GET_FUNC, 0, 0, pfunc, @@ -233,7 +233,7 @@ static int i2c_tiny_usb_probe(struct usb_interface *interface, dev_dbg(&interface->dev, "probing usb device\n"); /* allocate memory for our device state and initialize it */ - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) goto error; diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c index af1381949f50..01ef98e90243 100644 --- a/drivers/i2c/busses/i2c-virtio.c +++ b/drivers/i2c/busses/i2c-virtio.c @@ -139,7 +139,7 @@ static int virtio_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, struct virtio_i2c_req *reqs; int count; - reqs = kcalloc(num, sizeof(*reqs), GFP_KERNEL); + reqs = kzalloc_objs(*reqs, num, GFP_KERNEL); if (!reqs) return -ENOMEM; diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c index 06cf221557f2..1c76aef0a423 100644 --- a/drivers/i2c/busses/scx200_acb.c +++ b/drivers/i2c/busses/scx200_acb.c @@ -418,7 +418,7 @@ static struct scx200_acb_iface *scx200_create_iface(const char *text, struct scx200_acb_iface *iface; struct i2c_adapter *adapter; - iface = kzalloc(sizeof(*iface), GFP_KERNEL); + iface = kzalloc_obj(*iface, GFP_KERNEL); if (!iface) return NULL; diff --git a/drivers/i2c/i2c-atr.c b/drivers/i2c/i2c-atr.c index dd194476b118..8e3fe365caaf 100644 --- a/drivers/i2c/i2c-atr.c +++ b/drivers/i2c/i2c-atr.c @@ -137,7 +137,7 @@ static struct i2c_atr_alias_pool *i2c_atr_alloc_alias_pool(size_t num_aliases, b struct i2c_atr_alias_pool *alias_pool; int ret; - alias_pool = kzalloc(sizeof(*alias_pool), GFP_KERNEL); + alias_pool = kzalloc_obj(*alias_pool, GFP_KERNEL); if (!alias_pool) return ERR_PTR(-ENOMEM); @@ -183,7 +183,7 @@ static struct i2c_atr_alias_pair *i2c_atr_create_c2a(struct i2c_atr_chan *chan, lockdep_assert_held(&chan->alias_pairs_lock); - c2a = kzalloc(sizeof(*c2a), GFP_KERNEL); + c2a = kzalloc_obj(*c2a, GFP_KERNEL); if (!c2a) return NULL; @@ -724,7 +724,7 @@ struct i2c_atr *i2c_atr_new(struct i2c_adapter *parent, struct device *dev, if (!ops || !ops->attach_addr || !ops->detach_addr) return ERR_PTR(-EINVAL); - atr = kzalloc(struct_size(atr, adapter, max_adapters), GFP_KERNEL); + atr = kzalloc_flex(*atr, adapter, max_adapters, GFP_KERNEL); if (!atr) return ERR_PTR(-ENOMEM); @@ -800,7 +800,7 @@ int i2c_atr_add_adapter(struct i2c_atr *atr, struct i2c_atr_adap_desc *desc) return -EEXIST; } - chan = kzalloc(sizeof(*chan), GFP_KERNEL); + chan = kzalloc_obj(*chan, GFP_KERNEL); if (!chan) return -ENOMEM; diff --git a/drivers/i2c/i2c-boardinfo.c b/drivers/i2c/i2c-boardinfo.c index 4df8ad092df3..31fcc051bf20 100644 --- a/drivers/i2c/i2c-boardinfo.c +++ b/drivers/i2c/i2c-boardinfo.c @@ -61,7 +61,7 @@ int i2c_register_board_info(int busnum, struct i2c_board_info const *info, unsig for (status = 0; len; len--, info++) { struct i2c_devinfo *devinfo; - devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL); + devinfo = kzalloc_obj(*devinfo, GFP_KERNEL); if (!devinfo) { pr_debug("i2c-core: can't register boardinfo!\n"); status = -ENOMEM; diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c index ed90858a27b7..5b16d76a5bc2 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c @@ -683,7 +683,7 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command, if (ACPI_FAILURE(ret)) return ret; - client = kzalloc(sizeof(*client), GFP_KERNEL); + client = kzalloc_obj(*client, GFP_KERNEL); if (!client) { ret = AE_NO_MEMORY; goto err; @@ -793,8 +793,7 @@ int i2c_acpi_install_space_handler(struct i2c_adapter *adapter) if (!handle) return -ENODEV; - data = kzalloc(sizeof(struct i2c_acpi_handler_data), - GFP_KERNEL); + data = kzalloc_obj(struct i2c_acpi_handler_data, GFP_KERNEL); if (!data) return -ENOMEM; diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index f0fb0cfd56e0..91b388070525 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -964,7 +964,7 @@ i2c_new_client_device(struct i2c_adapter *adap, struct i2c_board_info const *inf bool need_put = false; int status; - client = kzalloc(sizeof *client, GFP_KERNEL); + client = kzalloc_obj(*client, GFP_KERNEL); if (!client) return ERR_PTR(-ENOMEM); @@ -2529,7 +2529,7 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver) return 0; /* Set up a temporary client to help detect callback */ - temp_client = kzalloc(sizeof(*temp_client), GFP_KERNEL); + temp_client = kzalloc_obj(*temp_client, GFP_KERNEL); if (!temp_client) return -ENOMEM; diff --git a/drivers/i2c/i2c-core-of-prober.c b/drivers/i2c/i2c-core-of-prober.c index 0a66267e4836..8c820d70846a 100644 --- a/drivers/i2c/i2c-core-of-prober.c +++ b/drivers/i2c/i2c-core-of-prober.c @@ -63,7 +63,7 @@ static int i2c_of_probe_enable_node(struct device *dev, struct device_node *node dev_dbg(dev, "Enabling %pOF\n", node); - struct of_changeset *ocs __free(kfree) = kzalloc(sizeof(*ocs), GFP_KERNEL); + struct of_changeset *ocs __free(kfree) = kzalloc_obj(*ocs, GFP_KERNEL); if (!ocs) return -ENOMEM; diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index e9577f920286..e4ac9f2df8d5 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c @@ -74,7 +74,7 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap) return ERR_PTR(-ENODEV); } - i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); + i2c_dev = kzalloc_obj(*i2c_dev, GFP_KERNEL); if (!i2c_dev) return ERR_PTR(-ENOMEM); i2c_dev->adap = adap; @@ -552,8 +552,8 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned lo if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS) return -EINVAL; - rdwr_pa = kmalloc_array(rdwr_arg.nmsgs, sizeof(struct i2c_msg), - GFP_KERNEL); + rdwr_pa = kmalloc_objs(struct i2c_msg, rdwr_arg.nmsgs, + GFP_KERNEL); if (!rdwr_pa) return -ENOMEM; @@ -612,7 +612,7 @@ static int i2cdev_open(struct inode *inode, struct file *file) * or I2C core code!! It just holds private copies of addressing * information and maybe a PEC flag. */ - client = kzalloc(sizeof(*client), GFP_KERNEL); + client = kzalloc_obj(*client, GFP_KERNEL); if (!client) { i2c_put_adapter(adap); return -ENOMEM; diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c index d59644e50f14..2e7b4073a4df 100644 --- a/drivers/i2c/i2c-mux.c +++ b/drivers/i2c/i2c-mux.c @@ -277,7 +277,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc, return -EINVAL; } - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (!priv) return -ENOMEM; diff --git a/drivers/i2c/i2c-smbus.c b/drivers/i2c/i2c-smbus.c index 0316b347f9e7..14e45590e97e 100644 --- a/drivers/i2c/i2c-smbus.c +++ b/drivers/i2c/i2c-smbus.c @@ -319,8 +319,7 @@ struct i2c_client *i2c_new_slave_host_notify_device(struct i2c_adapter *adapter) struct i2c_client *client; int ret; - status = kzalloc(sizeof(struct i2c_slave_host_notify_status), - GFP_KERNEL); + status = kzalloc_obj(struct i2c_slave_host_notify_status, GFP_KERNEL); if (!status) return ERR_PTR(-ENOMEM); diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c index 09e7b7bf4c5f..1d7d105c5643 100644 --- a/drivers/i2c/i2c-stub.c +++ b/drivers/i2c/i2c-stub.c @@ -372,8 +372,7 @@ static int __init i2c_stub_init(void) /* Allocate memory for all chips at once */ stub_chips_nr = i; - stub_chips = kcalloc(stub_chips_nr, sizeof(struct stub_chip), - GFP_KERNEL); + stub_chips = kzalloc_objs(struct stub_chip, stub_chips_nr, GFP_KERNEL); if (!stub_chips) return -ENOMEM; |
