summaryrefslogtreecommitdiff
path: root/drivers/mfd
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/mfd
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/mfd')
-rw-r--r--drivers/mfd/cros_ec_dev.c2
-rw-r--r--drivers/mfd/dln2.c4
-rw-r--r--drivers/mfd/ezx-pcap.c2
-rw-r--r--drivers/mfd/sm501.c4
-rw-r--r--drivers/mfd/syscon.c4
-rw-r--r--drivers/mfd/timberdale.c6
-rw-r--r--drivers/mfd/twl4030-irq.c2
-rw-r--r--drivers/mfd/ucb1x00-core.c4
-rw-r--r--drivers/mfd/ucb1x00-ts.c2
-rw-r--r--drivers/mfd/viperboard.c2
-rw-r--r--drivers/mfd/wm831x-auxadc.c2
11 files changed, 17 insertions, 17 deletions
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index dc80a272726b..777cb2a24983 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -188,7 +188,7 @@ static int ec_device_probe(struct platform_device *pdev)
struct device_node *node;
struct device *dev = &pdev->dev;
struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
- struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+ struct cros_ec_dev *ec = kzalloc_obj(*ec, GFP_KERNEL);
struct ec_response_pchg_count pchg_count;
int i;
diff --git a/drivers/mfd/dln2.c b/drivers/mfd/dln2.c
index fbbe82c6e75b..eb70156e5abf 100644
--- a/drivers/mfd/dln2.c
+++ b/drivers/mfd/dln2.c
@@ -125,7 +125,7 @@ int dln2_register_event_cb(struct platform_device *pdev, u16 id,
unsigned long flags;
int ret = 0;
- entry = kzalloc(sizeof(*entry), GFP_KERNEL);
+ entry = kzalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return -ENOMEM;
@@ -778,7 +778,7 @@ static int dln2_probe(struct usb_interface *interface,
if (ret)
return ret;
- dln2 = kzalloc(sizeof(*dln2), GFP_KERNEL);
+ dln2 = kzalloc_obj(*dln2, GFP_KERNEL);
if (!dln2)
return -ENOMEM;
diff --git a/drivers/mfd/ezx-pcap.c b/drivers/mfd/ezx-pcap.c
index 1be4557b7bdd..d98a02a073ac 100644
--- a/drivers/mfd/ezx-pcap.c
+++ b/drivers/mfd/ezx-pcap.c
@@ -302,7 +302,7 @@ int pcap_adc_async(struct pcap_chip *pcap, u8 bank, u32 flags, u8 ch[],
unsigned long irq_flags;
/* This will be freed after we have a result */
- req = kmalloc(sizeof(struct pcap_adc_request), GFP_KERNEL);
+ req = kmalloc_obj(struct pcap_adc_request, GFP_KERNEL);
if (!req)
return -ENOMEM;
diff --git a/drivers/mfd/sm501.c b/drivers/mfd/sm501.c
index 50bf3260f65d..ae6af552f6d2 100644
--- a/drivers/mfd/sm501.c
+++ b/drivers/mfd/sm501.c
@@ -1335,7 +1335,7 @@ static int sm501_plat_probe(struct platform_device *dev)
struct sm501_devdata *sm;
int ret;
- sm = kzalloc(sizeof(*sm), GFP_KERNEL);
+ sm = kzalloc_obj(*sm, GFP_KERNEL);
if (!sm) {
ret = -ENOMEM;
goto err1;
@@ -1518,7 +1518,7 @@ static int sm501_pci_probe(struct pci_dev *dev,
struct sm501_devdata *sm;
int err;
- sm = kzalloc(sizeof(*sm), GFP_KERNEL);
+ sm = kzalloc_obj(*sm, GFP_KERNEL);
if (!sm) {
err = -ENOMEM;
goto err1;
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index e5d5def594f6..6bf0bcf49ff4 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -51,7 +51,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
WARN_ON(!mutex_is_locked(&syscon_list_lock));
- struct syscon *syscon __free(kfree) = kzalloc(sizeof(*syscon), GFP_KERNEL);
+ struct syscon *syscon __free(kfree) = kzalloc_obj(*syscon, GFP_KERNEL);
if (!syscon)
return ERR_PTR(-ENOMEM);
@@ -212,7 +212,7 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
if (!np || !regmap)
return -EINVAL;
- syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
+ syscon = kzalloc_obj(*syscon, GFP_KERNEL);
if (!syscon)
return -ENOMEM;
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c
index b059713db875..b44af8ca1360 100644
--- a/drivers/mfd/timberdale.c
+++ b/drivers/mfd/timberdale.c
@@ -649,7 +649,7 @@ static int timb_probe(struct pci_dev *dev,
struct msix_entry *msix_entries = NULL;
u8 ip_setup;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -698,8 +698,8 @@ static int timb_probe(struct pci_dev *dev,
goto err_config;
}
- msix_entries = kcalloc(TIMBERDALE_NR_IRQS, sizeof(*msix_entries),
- GFP_KERNEL);
+ msix_entries = kzalloc_objs(*msix_entries, TIMBERDALE_NR_IRQS,
+ GFP_KERNEL);
if (!msix_entries)
goto err_config;
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index d3ab40651307..4def9eeb964f 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -631,7 +631,7 @@ int twl4030_sih_setup(struct device *dev, int module, int irq_base)
return status;
}
- agent = kzalloc(sizeof(*agent), GFP_KERNEL);
+ agent = kzalloc_obj(*agent, GFP_KERNEL);
if (!agent)
return -ENOMEM;
diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
index 4b450d78a65f..b2f304984505 100644
--- a/drivers/mfd/ucb1x00-core.c
+++ b/drivers/mfd/ucb1x00-core.c
@@ -395,7 +395,7 @@ static int ucb1x00_add_dev(struct ucb1x00 *ucb, struct ucb1x00_driver *drv)
struct ucb1x00_dev *dev;
int ret;
- dev = kmalloc(sizeof(struct ucb1x00_dev), GFP_KERNEL);
+ dev = kmalloc_obj(struct ucb1x00_dev, GFP_KERNEL);
if (!dev)
return -ENOMEM;
@@ -513,7 +513,7 @@ static int ucb1x00_probe(struct mcp *mcp)
goto out;
}
- ucb = kzalloc(sizeof(struct ucb1x00), GFP_KERNEL);
+ ucb = kzalloc_obj(struct ucb1x00, GFP_KERNEL);
ret = -ENOMEM;
if (!ucb)
goto out;
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 6e1b38f9f26c..ff1b018969d5 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -367,7 +367,7 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
struct input_dev *idev;
int err;
- ts = kzalloc(sizeof(struct ucb1x00_ts), GFP_KERNEL);
+ ts = kzalloc_obj(struct ucb1x00_ts, GFP_KERNEL);
idev = input_allocate_device();
if (!ts || !idev) {
err = -ENOMEM;
diff --git a/drivers/mfd/viperboard.c b/drivers/mfd/viperboard.c
index ba867b7ecfad..7c0b1ae0c6bc 100644
--- a/drivers/mfd/viperboard.c
+++ b/drivers/mfd/viperboard.c
@@ -53,7 +53,7 @@ static int vprbrd_probe(struct usb_interface *interface,
int pipe, ret;
/* allocate memory for our device state and initialize it */
- vb = kzalloc(sizeof(*vb), GFP_KERNEL);
+ vb = kzalloc_obj(*vb, GFP_KERNEL);
if (!vb)
return -ENOMEM;
diff --git a/drivers/mfd/wm831x-auxadc.c b/drivers/mfd/wm831x-auxadc.c
index 18618a8f9206..5db027c904ad 100644
--- a/drivers/mfd/wm831x-auxadc.c
+++ b/drivers/mfd/wm831x-auxadc.c
@@ -35,7 +35,7 @@ static int wm831x_auxadc_read_irq(struct wm831x *wm831x,
int ret;
bool ena = false;
- req = kzalloc(sizeof(*req), GFP_KERNEL);
+ req = kzalloc_obj(*req, GFP_KERNEL);
if (!req)
return -ENOMEM;