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/keyboard | |
| 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/keyboard')
| -rw-r--r-- | drivers/input/keyboard/atkbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/lkkbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/locomokbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/maple_keyb.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/newtonkbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/omap-keypad.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/sh_keysc.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/stowaway.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/sunkbd.c | 2 | ||||
| -rw-r--r-- | drivers/input/keyboard/xtkbd.c | 2 |
11 files changed, 11 insertions, 11 deletions
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 422e28ad1e8e..f149ed800a45 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -1277,7 +1277,7 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) struct input_dev *dev; int err = -ENOMEM; - atkbd = kzalloc(sizeof(*atkbd), GFP_KERNEL); + atkbd = kzalloc_obj(*atkbd, GFP_KERNEL); dev = input_allocate_device(); if (!atkbd || !dev) goto fail1; diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 54afb38601b9..8f246865a5ee 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c @@ -447,7 +447,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv) uint8_t did, *idd; int error; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); input_dev = input_allocate_device(); if (!dev || !input_dev) { error = -ENOMEM; diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c index 2f130f819363..f0daee8887cb 100644 --- a/drivers/input/keyboard/lkkbd.c +++ b/drivers/input/keyboard/lkkbd.c @@ -608,7 +608,7 @@ static int lkkbd_connect(struct serio *serio, struct serio_driver *drv) int i; int err; - lk = kzalloc(sizeof(*lk), GFP_KERNEL); + lk = kzalloc_obj(*lk, GFP_KERNEL); input_dev = input_allocate_device(); if (!lk || !input_dev) { err = -ENOMEM; diff --git a/drivers/input/keyboard/locomokbd.c b/drivers/input/keyboard/locomokbd.c index 58d4f2096cf9..b6b9354b3354 100644 --- a/drivers/input/keyboard/locomokbd.c +++ b/drivers/input/keyboard/locomokbd.c @@ -224,7 +224,7 @@ static int locomokbd_probe(struct locomo_dev *dev) struct input_dev *input_dev; int i, err; - locomokbd = kzalloc(sizeof(*locomokbd), GFP_KERNEL); + locomokbd = kzalloc_obj(*locomokbd, GFP_KERNEL); input_dev = input_allocate_device(); if (!locomokbd || !input_dev) { err = -ENOMEM; diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index 1a8f1fa53fbb..52dfdcab55f2 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c @@ -151,7 +151,7 @@ static int probe_maple_kbd(struct device *dev) mdev = to_maple_dev(dev); mdrv = to_maple_driver(dev->driver); - kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); + kbd = kzalloc_obj(*kbd, GFP_KERNEL); if (!kbd) { error = -ENOMEM; goto fail; diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 71e0a3f830dd..ee142a2d7c84 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c @@ -68,7 +68,7 @@ static int nkbd_connect(struct serio *serio, struct serio_driver *drv) int err = -ENOMEM; int i; - nkbd = kzalloc(sizeof(*nkbd), GFP_KERNEL); + nkbd = kzalloc_obj(*nkbd, GFP_KERNEL); input_dev = input_allocate_device(); if (!nkbd || !input_dev) goto fail1; diff --git a/drivers/input/keyboard/omap-keypad.c b/drivers/input/keyboard/omap-keypad.c index 9e13f3f70a81..8fd909407ec8 100644 --- a/drivers/input/keyboard/omap-keypad.c +++ b/drivers/input/keyboard/omap-keypad.c @@ -193,7 +193,7 @@ static int omap_kp_probe(struct platform_device *pdev) row_shift = get_count_order(pdata->cols); keycodemax = pdata->rows << row_shift; - omap_kp = kzalloc(struct_size(omap_kp, keymap, keycodemax), GFP_KERNEL); + omap_kp = kzalloc_flex(*omap_kp, keymap, keycodemax, GFP_KERNEL); input_dev = input_allocate_device(); if (!omap_kp || !input_dev) { kfree(omap_kp); diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index 159f41eedd41..7ad799efc539 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c @@ -184,7 +184,7 @@ static int sh_keysc_probe(struct platform_device *pdev) if (irq < 0) goto err0; - priv = kzalloc(sizeof(*priv), GFP_KERNEL); + priv = kzalloc_obj(*priv, GFP_KERNEL); if (priv == NULL) { dev_err(&pdev->dev, "failed to allocate driver data\n"); error = -ENOMEM; diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c index 7ef0b3f4f549..592801876291 100644 --- a/drivers/input/keyboard/stowaway.c +++ b/drivers/input/keyboard/stowaway.c @@ -72,7 +72,7 @@ static int skbd_connect(struct serio *serio, struct serio_driver *drv) int err = -ENOMEM; int i; - skbd = kzalloc(sizeof(*skbd), GFP_KERNEL); + skbd = kzalloc_obj(*skbd, GFP_KERNEL); input_dev = input_allocate_device(); if (!skbd || !input_dev) goto fail1; diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 3299e1919b37..d2783e9a5583 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c @@ -262,7 +262,7 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) int err = -ENOMEM; int i; - sunkbd = kzalloc(sizeof(*sunkbd), GFP_KERNEL); + sunkbd = kzalloc_obj(*sunkbd, GFP_KERNEL); input_dev = input_allocate_device(); if (!sunkbd || !input_dev) goto fail1; diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index befa713268ae..ce061bd76623 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c @@ -70,7 +70,7 @@ static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) int err = -ENOMEM; int i; - xtkbd = kmalloc(sizeof(*xtkbd), GFP_KERNEL); + xtkbd = kmalloc_obj(*xtkbd, GFP_KERNEL); input_dev = input_allocate_device(); if (!xtkbd || !input_dev) goto fail1; |
