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/input/misc | |
| 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/input/misc')
| -rw-r--r-- | drivers/input/misc/88pm80x_onkey.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/ati_remote2.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/cm109.c | 4 | ||||
| -rw-r--r-- | drivers/input/misc/cma3000_d0x.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/cs40l50-vibra.c | 4 | ||||
| -rw-r--r-- | drivers/input/misc/da9052_onkey.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/ims-pcu.c | 4 | ||||
| -rw-r--r-- | drivers/input/misc/keyspan_remote.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/max8997_haptic.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/mc13783-pwrbutton.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/palmas-pwrbutton.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/pcap_keys.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/pcf8574_keypad.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/powermate.c | 4 | ||||
| -rw-r--r-- | drivers/input/misc/uinput.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/xen-kbdfront.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/yealink.c | 4 |
17 files changed, 22 insertions, 22 deletions
diff --git a/drivers/input/misc/88pm80x_onkey.c b/drivers/input/misc/88pm80x_onkey.c index 9159b5fec129..32d2f4450b7c 100644 --- a/drivers/input/misc/88pm80x_onkey.c +++ b/drivers/input/misc/88pm80x_onkey.c @@ -57,7 +57,7 @@ static int pm80x_onkey_probe(struct platform_device *pdev) struct pm80x_onkey_info *info; int err; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) return -ENOMEM; diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index e84649af801d..faa03c0b8c92 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c @@ -772,7 +772,7 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d if (alt->desc.bInterfaceNumber) return -ENODEV; - ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL); + ar2 = kzalloc_obj(struct ati_remote2, GFP_KERNEL); if (!ar2) return -ENOMEM; diff --git a/drivers/input/misc/cm109.c b/drivers/input/misc/cm109.c index 0cfe5d4a573c..3fbdd160fb2c 100644 --- a/drivers/input/misc/cm109.c +++ b/drivers/input/misc/cm109.c @@ -696,7 +696,7 @@ static int cm109_usb_probe(struct usb_interface *intf, if (!usb_endpoint_is_int_in(endpoint)) return -ENODEV; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) return -ENOMEM; @@ -721,7 +721,7 @@ static int cm109_usb_probe(struct usb_interface *intf, if (!dev->ctl_data) goto err_out; - dev->ctl_req = kmalloc(sizeof(*(dev->ctl_req)), GFP_KERNEL); + dev->ctl_req = kmalloc_obj(*(dev->ctl_req), GFP_KERNEL); if (!dev->ctl_req) goto err_out; diff --git a/drivers/input/misc/cma3000_d0x.c b/drivers/input/misc/cma3000_d0x.c index b4232b0a3957..b5047f74f632 100644 --- a/drivers/input/misc/cma3000_d0x.c +++ b/drivers/input/misc/cma3000_d0x.c @@ -285,7 +285,7 @@ struct cma3000_accl_data *cma3000_init(struct device *dev, int irq, goto err_out; } - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = kzalloc_obj(*data, GFP_KERNEL); input_dev = input_allocate_device(); if (!data || !input_dev) { error = -ENOMEM; diff --git a/drivers/input/misc/cs40l50-vibra.c b/drivers/input/misc/cs40l50-vibra.c index 90410025bbae..e6c8c9d165d3 100644 --- a/drivers/input/misc/cs40l50-vibra.c +++ b/drivers/input/misc/cs40l50-vibra.c @@ -276,7 +276,7 @@ static void cs40l50_add_worker(struct work_struct *work) /* Update effect if already uploaded, otherwise create new effect */ effect = cs40l50_find_effect(work_data->effect->id, &vib->effect_head); if (!effect) { - effect = kzalloc(sizeof(*effect), GFP_KERNEL); + effect = kzalloc_obj(*effect, GFP_KERNEL); if (!effect) { error = -ENOMEM; goto err_pm; @@ -392,7 +392,7 @@ static int cs40l50_playback(struct input_dev *dev, int effect_id, int val) struct cs40l50_vibra *vib = input_get_drvdata(dev); struct cs40l50_work *work_data; - work_data = kzalloc(sizeof(*work_data), GFP_ATOMIC); + work_data = kzalloc_obj(*work_data, GFP_ATOMIC); if (!work_data) return -ENOMEM; diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c index cc23625019e3..49112b3ff445 100644 --- a/drivers/input/misc/da9052_onkey.c +++ b/drivers/input/misc/da9052_onkey.c @@ -80,7 +80,7 @@ static int da9052_onkey_probe(struct platform_device *pdev) return -EINVAL; } - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL); + onkey = kzalloc_obj(*onkey, GFP_KERNEL); input_dev = input_allocate_device(); if (!onkey || !input_dev) { dev_err(&pdev->dev, "Failed to allocate memory\n"); diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 4581f1c53644..52ad6e3a8112 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -286,7 +286,7 @@ static int ims_pcu_setup_gamepad(struct ims_pcu *pcu) struct input_dev *input; int error; - gamepad = kzalloc(sizeof(*gamepad), GFP_KERNEL); + gamepad = kzalloc_obj(*gamepad, GFP_KERNEL); input = input_allocate_device(); if (!gamepad || !input) { dev_err(pcu->dev, @@ -1991,7 +1991,7 @@ static int ims_pcu_probe(struct usb_interface *intf, struct ims_pcu *pcu; int error; - pcu = kzalloc(sizeof(*pcu), GFP_KERNEL); + pcu = kzalloc_obj(*pcu, GFP_KERNEL); if (!pcu) return -ENOMEM; diff --git a/drivers/input/misc/keyspan_remote.c b/drivers/input/misc/keyspan_remote.c index bee4b1376491..219a7a92e5b6 100644 --- a/drivers/input/misc/keyspan_remote.c +++ b/drivers/input/misc/keyspan_remote.c @@ -453,7 +453,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic if (!endpoint) return -ENODEV; - remote = kzalloc(sizeof(*remote), GFP_KERNEL); + remote = kzalloc_obj(*remote, GFP_KERNEL); input_dev = input_allocate_device(); if (!remote || !input_dev) { error = -ENOMEM; diff --git a/drivers/input/misc/max8997_haptic.c b/drivers/input/misc/max8997_haptic.c index d5e051a25a74..290c03d8b972 100644 --- a/drivers/input/misc/max8997_haptic.c +++ b/drivers/input/misc/max8997_haptic.c @@ -247,7 +247,7 @@ static int max8997_haptic_probe(struct platform_device *pdev) return -EINVAL; } - chip = kzalloc(sizeof(*chip), GFP_KERNEL); + chip = kzalloc_obj(*chip, GFP_KERNEL); input_dev = input_allocate_device(); if (!chip || !input_dev) { dev_err(&pdev->dev, "unable to allocate memory\n"); diff --git a/drivers/input/misc/mc13783-pwrbutton.c b/drivers/input/misc/mc13783-pwrbutton.c index b83d762ae2e9..d75af824033a 100644 --- a/drivers/input/misc/mc13783-pwrbutton.c +++ b/drivers/input/misc/mc13783-pwrbutton.c @@ -108,7 +108,7 @@ static int mc13783_pwrbutton_probe(struct platform_device *pdev) return -ENOMEM; } - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (!priv) { err = -ENOMEM; dev_dbg(&pdev->dev, "Can't allocate power button\n"); diff --git a/drivers/input/misc/palmas-pwrbutton.c b/drivers/input/misc/palmas-pwrbutton.c index d9c5aae143dc..c1608cdee7f2 100644 --- a/drivers/input/misc/palmas-pwrbutton.c +++ b/drivers/input/misc/palmas-pwrbutton.c @@ -164,7 +164,7 @@ static int palmas_pwron_probe(struct platform_device *pdev) palmas_pwron_params_ofinit(dev, &config); - pwron = kzalloc(sizeof(*pwron), GFP_KERNEL); + pwron = kzalloc_obj(*pwron, GFP_KERNEL); if (!pwron) return -ENOMEM; diff --git a/drivers/input/misc/pcap_keys.c b/drivers/input/misc/pcap_keys.c index fe43fd72ba7b..003bc50f83a6 100644 --- a/drivers/input/misc/pcap_keys.c +++ b/drivers/input/misc/pcap_keys.c @@ -49,7 +49,7 @@ static int pcap_keys_probe(struct platform_device *pdev) struct pcap_keys *pcap_keys; struct input_dev *input_dev; - pcap_keys = kmalloc(sizeof(*pcap_keys), GFP_KERNEL); + pcap_keys = kmalloc_obj(*pcap_keys, GFP_KERNEL); if (!pcap_keys) return err; diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c index 3632cb206e34..bcef6a251237 100644 --- a/drivers/input/misc/pcf8574_keypad.c +++ b/drivers/input/misc/pcf8574_keypad.c @@ -91,7 +91,7 @@ static int pcf8574_kp_probe(struct i2c_client *client) return -ENODEV; } - lp = kzalloc(sizeof(*lp), GFP_KERNEL); + lp = kzalloc_obj(*lp, GFP_KERNEL); if (!lp) return -ENOMEM; diff --git a/drivers/input/misc/powermate.c b/drivers/input/misc/powermate.c index ecb92ee5ebbc..dfcab914d5f3 100644 --- a/drivers/input/misc/powermate.c +++ b/drivers/input/misc/powermate.c @@ -275,7 +275,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev if (!pm->data) return -1; - pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL); + pm->configcr = kmalloc_obj(*(pm->configcr), GFP_KERNEL); if (!pm->configcr) return -ENOMEM; @@ -313,7 +313,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i 0, interface->desc.bInterfaceNumber, NULL, 0, USB_CTRL_SET_TIMEOUT); - pm = kzalloc(sizeof(*pm), GFP_KERNEL); + pm = kzalloc_obj(*pm, GFP_KERNEL); input_dev = input_allocate_device(); if (!pm || !input_dev) goto fail1; diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 13336a2fd49c..f34bda9b1a74 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -379,7 +379,7 @@ static int uinput_open(struct inode *inode, struct file *file) { struct uinput_device *newdev; - newdev = kzalloc(sizeof(*newdev), GFP_KERNEL); + newdev = kzalloc_obj(*newdev, GFP_KERNEL); if (!newdev) return -ENOMEM; diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c index 67f1c7364c95..b046df24a433 100644 --- a/drivers/input/misc/xen-kbdfront.c +++ b/drivers/input/misc/xen-kbdfront.c @@ -205,7 +205,7 @@ static int xenkbd_probe(struct xenbus_device *dev, struct xenkbd_info *info; struct input_dev *kbd, *ptr, *mtouch; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc_obj(*info, GFP_KERNEL); if (!info) { xenbus_dev_fatal(dev, -ENOMEM, "allocating info structure"); return -ENOMEM; diff --git a/drivers/input/misc/yealink.c b/drivers/input/misc/yealink.c index 08dc53ae1b3c..10a85f60f6d1 100644 --- a/drivers/input/misc/yealink.c +++ b/drivers/input/misc/yealink.c @@ -831,7 +831,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (!usb_endpoint_is_int_in(endpoint)) return -ENODEV; - yld = kzalloc(sizeof(*yld), GFP_KERNEL); + yld = kzalloc_obj(*yld, GFP_KERNEL); if (!yld) return -ENOMEM; @@ -854,7 +854,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id) if (!yld->ctl_data) return usb_cleanup(yld, -ENOMEM); - yld->ctl_req = kmalloc(sizeof(*(yld->ctl_req)), GFP_KERNEL); + yld->ctl_req = kmalloc_obj(*(yld->ctl_req), GFP_KERNEL); if (yld->ctl_req == NULL) return usb_cleanup(yld, -ENOMEM); |
