summaryrefslogtreecommitdiff
path: root/drivers/input/joystick
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/input/joystick
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.zip
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/joystick')
-rw-r--r--drivers/input/joystick/a3d.c2
-rw-r--r--drivers/input/joystick/adi.c2
-rw-r--r--drivers/input/joystick/analog.c2
-rw-r--r--drivers/input/joystick/as5011.c2
-rw-r--r--drivers/input/joystick/cobra.c2
-rw-r--r--drivers/input/joystick/db9.c2
-rw-r--r--drivers/input/joystick/fsia6b.c2
-rw-r--r--drivers/input/joystick/gamecon.c4
-rw-r--r--drivers/input/joystick/gf2k.c2
-rw-r--r--drivers/input/joystick/grip.c2
-rw-r--r--drivers/input/joystick/grip_mp.c2
-rw-r--r--drivers/input/joystick/guillemot.c2
-rw-r--r--drivers/input/joystick/iforce/iforce-serio.c2
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c2
-rw-r--r--drivers/input/joystick/interact.c2
-rw-r--r--drivers/input/joystick/joydump.c2
-rw-r--r--drivers/input/joystick/magellan.c2
-rw-r--r--drivers/input/joystick/maplecontrol.c2
-rw-r--r--drivers/input/joystick/n64joy.c2
-rw-r--r--drivers/input/joystick/sidewinder.c2
-rw-r--r--drivers/input/joystick/spaceball.c2
-rw-r--r--drivers/input/joystick/spaceorb.c2
-rw-r--r--drivers/input/joystick/stinger.c2
-rw-r--r--drivers/input/joystick/tmdc.c4
-rw-r--r--drivers/input/joystick/turbografx.c2
-rw-r--r--drivers/input/joystick/twidjoy.c2
-rw-r--r--drivers/input/joystick/warrior.c2
-rw-r--r--drivers/input/joystick/xpad.c4
-rw-r--r--drivers/input/joystick/zhenhua.c2
29 files changed, 32 insertions, 32 deletions
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c
index 15182f16ed19..07bd0083d654 100644
--- a/drivers/input/joystick/a3d.c
+++ b/drivers/input/joystick/a3d.c
@@ -249,7 +249,7 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- a3d = kzalloc(sizeof(*a3d), GFP_KERNEL);
+ a3d = kzalloc_obj(*a3d, GFP_KERNEL);
input_dev = input_allocate_device();
if (!a3d || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index 963250de24b7..fa7d0b80e7b7 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -456,7 +456,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c
index c709b58d770a..79ed2363b8e5 100644
--- a/drivers/input/joystick/analog.c
+++ b/drivers/input/joystick/analog.c
@@ -582,7 +582,7 @@ static int analog_connect(struct gameport *gameport, struct gameport_driver *drv
int i;
int err;
- port = kzalloc(sizeof(*port), GFP_KERNEL);
+ port = kzalloc_obj(*port, GFP_KERNEL);
if (!port)
return -ENOMEM;
diff --git a/drivers/input/joystick/as5011.c b/drivers/input/joystick/as5011.c
index 49a0dfbbeb49..2d1a23866e64 100644
--- a/drivers/input/joystick/as5011.c
+++ b/drivers/input/joystick/as5011.c
@@ -237,7 +237,7 @@ static int as5011_probe(struct i2c_client *client)
return -ENODEV;
}
- as5011 = kmalloc(sizeof(*as5011), GFP_KERNEL);
+ as5011 = kmalloc_obj(*as5011, GFP_KERNEL);
input_dev = input_allocate_device();
if (!as5011 || !input_dev) {
dev_err(&client->dev,
diff --git a/drivers/input/joystick/cobra.c b/drivers/input/joystick/cobra.c
index 5a0ea3ad5efa..781cec6b2b24 100644
--- a/drivers/input/joystick/cobra.c
+++ b/drivers/input/joystick/cobra.c
@@ -141,7 +141,7 @@ static int cobra_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j;
int err;
- cobra = kzalloc(sizeof(*cobra), GFP_KERNEL);
+ cobra = kzalloc_obj(*cobra, GFP_KERNEL);
if (!cobra)
return -ENOMEM;
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c
index d5c67a927404..165096fc0a55 100644
--- a/drivers/input/joystick/db9.c
+++ b/drivers/input/joystick/db9.c
@@ -585,7 +585,7 @@ static void db9_attach(struct parport *pp)
return;
}
- db9 = kzalloc(sizeof(*db9), GFP_KERNEL);
+ db9 = kzalloc_obj(*db9, GFP_KERNEL);
if (!db9)
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/fsia6b.c b/drivers/input/joystick/fsia6b.c
index 7e3bc99d766f..0bd7d4bd562a 100644
--- a/drivers/input/joystick/fsia6b.c
+++ b/drivers/input/joystick/fsia6b.c
@@ -132,7 +132,7 @@ static int fsia6b_serio_connect(struct serio *serio, struct serio_driver *drv)
int i, j;
int sw_id = 0;
- fsia6b = kzalloc(sizeof(*fsia6b), GFP_KERNEL);
+ fsia6b = kzalloc_obj(*fsia6b, GFP_KERNEL);
if (!fsia6b)
return -ENOMEM;
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index ae95cb3d0ae9..03d0e491b688 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -291,7 +291,7 @@ static int gc_n64_init_ff(struct input_dev *dev, int i)
struct gc_subdev *sdev;
int err;
- sdev = kmalloc(sizeof(*sdev), GFP_KERNEL);
+ sdev = kmalloc_obj(*sdev, GFP_KERNEL);
if (!sdev)
return -ENOMEM;
@@ -948,7 +948,7 @@ static void gc_attach(struct parport *pp)
return;
}
- gc = kzalloc(sizeof(*gc), GFP_KERNEL);
+ gc = kzalloc_obj(*gc, GFP_KERNEL);
if (!gc) {
pr_err("Not enough memory\n");
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c
index e7ff7bdb1a3a..23dc98146ccd 100644
--- a/drivers/input/joystick/gf2k.c
+++ b/drivers/input/joystick/gf2k.c
@@ -222,7 +222,7 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv)
unsigned char data[GF2K_LENGTH];
int i, err;
- gf2k = kzalloc(sizeof(*gf2k), GFP_KERNEL);
+ gf2k = kzalloc_obj(*gf2k, GFP_KERNEL);
input_dev = input_allocate_device();
if (!gf2k || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/grip.c b/drivers/input/joystick/grip.c
index f339ce2b7a33..f500a32d1ea7 100644
--- a/drivers/input/joystick/grip.c
+++ b/drivers/input/joystick/grip.c
@@ -284,7 +284,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
int i, j, t;
int err;
- grip = kzalloc(sizeof(*grip), GFP_KERNEL);
+ grip = kzalloc_obj(*grip, GFP_KERNEL);
if (!grip)
return -ENOMEM;
diff --git a/drivers/input/joystick/grip_mp.c b/drivers/input/joystick/grip_mp.c
index 5eadb5a3ca37..7d90d8e5485b 100644
--- a/drivers/input/joystick/grip_mp.c
+++ b/drivers/input/joystick/grip_mp.c
@@ -632,7 +632,7 @@ static int grip_connect(struct gameport *gameport, struct gameport_driver *drv)
struct grip_mp *grip;
int err;
- grip = kzalloc(sizeof(*grip), GFP_KERNEL);
+ grip = kzalloc_obj(*grip, GFP_KERNEL);
if (!grip)
return -ENOMEM;
diff --git a/drivers/input/joystick/guillemot.c b/drivers/input/joystick/guillemot.c
index 1c5a76f72239..eb7faaf3f020 100644
--- a/drivers/input/joystick/guillemot.c
+++ b/drivers/input/joystick/guillemot.c
@@ -163,7 +163,7 @@ static int guillemot_connect(struct gameport *gameport, struct gameport_driver *
int i, t;
int err;
- guillemot = kzalloc(sizeof(*guillemot), GFP_KERNEL);
+ guillemot = kzalloc_obj(*guillemot, GFP_KERNEL);
input_dev = input_allocate_device();
if (!guillemot || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c
index 75b85c46dfa4..0ca2f9bfb17b 100644
--- a/drivers/input/joystick/iforce/iforce-serio.c
+++ b/drivers/input/joystick/iforce/iforce-serio.c
@@ -185,7 +185,7 @@ static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv)
struct iforce_serio *iforce_serio;
int err;
- iforce_serio = kzalloc(sizeof(*iforce_serio), GFP_KERNEL);
+ iforce_serio = kzalloc_obj(*iforce_serio, GFP_KERNEL);
if (!iforce_serio)
return -ENOMEM;
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 1f00f76b0174..b41d0b962e3d 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -207,7 +207,7 @@ static int iforce_usb_probe(struct usb_interface *intf,
if (!usb_endpoint_is_int_out(epout))
return -ENODEV;
- iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL);
+ iforce_usb = kzalloc_obj(*iforce_usb, GFP_KERNEL);
if (!iforce_usb)
goto fail;
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c
index 262f022e5695..88aa77d1fc36 100644
--- a/drivers/input/joystick/interact.c
+++ b/drivers/input/joystick/interact.c
@@ -192,7 +192,7 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d
int i, t;
int err;
- interact = kzalloc(sizeof(*interact), GFP_KERNEL);
+ interact = kzalloc_obj(*interact, GFP_KERNEL);
input_dev = input_allocate_device();
if (!interact || !input_dev) {
err = -ENOMEM;
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c
index 865652a7821d..9feda59dccde 100644
--- a/drivers/input/joystick/joydump.c
+++ b/drivers/input/joystick/joydump.c
@@ -61,7 +61,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr
timeout = gameport_time(gameport, 10000); /* 10 ms */
- buf = kmalloc_array(BUF_SIZE, sizeof(struct joydump), GFP_KERNEL);
+ buf = kmalloc_objs(struct joydump, BUF_SIZE, GFP_KERNEL);
if (!buf) {
printk(KERN_INFO "joydump: no memory for testing\n");
goto jd_end;
diff --git a/drivers/input/joystick/magellan.c b/drivers/input/joystick/magellan.c
index 7622638e5bb8..3b7f5840caeb 100644
--- a/drivers/input/joystick/magellan.c
+++ b/drivers/input/joystick/magellan.c
@@ -132,7 +132,7 @@ static int magellan_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- magellan = kzalloc(sizeof(*magellan), GFP_KERNEL);
+ magellan = kzalloc_obj(*magellan, GFP_KERNEL);
input_dev = input_allocate_device();
if (!magellan || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/maplecontrol.c b/drivers/input/joystick/maplecontrol.c
index 8b54f9b18e7c..2a811f302173 100644
--- a/drivers/input/joystick/maplecontrol.c
+++ b/drivers/input/joystick/maplecontrol.c
@@ -102,7 +102,7 @@ static int probe_maple_controller(struct device *dev)
struct input_dev *idev;
unsigned long data = be32_to_cpu(mdev->devinfo.function_data[0]);
- pad = kzalloc(sizeof(*pad), GFP_KERNEL);
+ pad = kzalloc_obj(*pad, GFP_KERNEL);
idev = input_allocate_device();
if (!pad || !idev) {
error = -ENOMEM;
diff --git a/drivers/input/joystick/n64joy.c b/drivers/input/joystick/n64joy.c
index 94d2f4e96fe6..b4203825e9e6 100644
--- a/drivers/input/joystick/n64joy.c
+++ b/drivers/input/joystick/n64joy.c
@@ -243,7 +243,7 @@ static int __init n64joy_probe(struct platform_device *pdev)
int err = 0;
u32 i, j, found = 0;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
mutex_init(&priv->n64joy_mutex);
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
index 3a5873e5fcb3..645c822638ad 100644
--- a/drivers/input/joystick/sidewinder.c
+++ b/drivers/input/joystick/sidewinder.c
@@ -578,7 +578,7 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv)
comment[0] = 0;
- sw = kzalloc(sizeof(*sw), GFP_KERNEL);
+ sw = kzalloc_obj(*sw, GFP_KERNEL);
buf = kmalloc(SW_LENGTH, GFP_KERNEL);
idbuf = kmalloc(SW_LENGTH, GFP_KERNEL);
if (!sw || !buf || !idbuf) {
diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
index 4f2221001a95..d562275aa4bc 100644
--- a/drivers/input/joystick/spaceball.c
+++ b/drivers/input/joystick/spaceball.c
@@ -199,7 +199,7 @@ static int spaceball_connect(struct serio *serio, struct serio_driver *drv)
if ((id = serio->id.id) > SPACEBALL_MAX_ID)
return -ENODEV;
- spaceball = kmalloc(sizeof(*spaceball), GFP_KERNEL);
+ spaceball = kmalloc_obj(*spaceball, GFP_KERNEL);
input_dev = input_allocate_device();
if (!spaceball || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/spaceorb.c b/drivers/input/joystick/spaceorb.c
index 7250d74d62a1..3aee84c19a25 100644
--- a/drivers/input/joystick/spaceorb.c
+++ b/drivers/input/joystick/spaceorb.c
@@ -147,7 +147,7 @@ static int spaceorb_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- spaceorb = kzalloc(sizeof(*spaceorb), GFP_KERNEL);
+ spaceorb = kzalloc_obj(*spaceorb, GFP_KERNEL);
input_dev = input_allocate_device();
if (!spaceorb || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/stinger.c b/drivers/input/joystick/stinger.c
index 1b24ea21aa30..81d4d1aa1752 100644
--- a/drivers/input/joystick/stinger.c
+++ b/drivers/input/joystick/stinger.c
@@ -118,7 +118,7 @@ static int stinger_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- stinger = kmalloc(sizeof(*stinger), GFP_KERNEL);
+ stinger = kmalloc_obj(*stinger, GFP_KERNEL);
input_dev = input_allocate_device();
if (!stinger || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/tmdc.c b/drivers/input/joystick/tmdc.c
index 514b1026e379..8d1367fdc400 100644
--- a/drivers/input/joystick/tmdc.c
+++ b/drivers/input/joystick/tmdc.c
@@ -264,7 +264,7 @@ static int tmdc_setup_port(struct tmdc *tmdc, int idx, unsigned char *data)
int i, j, b = 0;
int err;
- tmdc->port[idx] = port = kzalloc(sizeof (struct tmdc_port), GFP_KERNEL);
+ tmdc->port[idx] = port = kzalloc_obj(struct tmdc_port, GFP_KERNEL);
input_dev = input_allocate_device();
if (!port || !input_dev) {
err = -ENOMEM;
@@ -348,7 +348,7 @@ static int tmdc_connect(struct gameport *gameport, struct gameport_driver *drv)
int i;
int err;
- tmdc = kzalloc(sizeof(*tmdc), GFP_KERNEL);
+ tmdc = kzalloc_obj(*tmdc, GFP_KERNEL);
if (!tmdc)
return -ENOMEM;
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c
index 5f69aef01791..90cddb12efbb 100644
--- a/drivers/input/joystick/turbografx.c
+++ b/drivers/input/joystick/turbografx.c
@@ -170,7 +170,7 @@ static void tgfx_attach(struct parport *pp)
return;
}
- tgfx = kzalloc(sizeof(*tgfx), GFP_KERNEL);
+ tgfx = kzalloc_obj(*tgfx, GFP_KERNEL);
if (!tgfx) {
printk(KERN_ERR "turbografx.c: Not enough memory\n");
goto err_unreg_pardev;
diff --git a/drivers/input/joystick/twidjoy.c b/drivers/input/joystick/twidjoy.c
index ab99d76e5d8d..e8f81d3a4d99 100644
--- a/drivers/input/joystick/twidjoy.c
+++ b/drivers/input/joystick/twidjoy.c
@@ -171,7 +171,7 @@ static int twidjoy_connect(struct serio *serio, struct serio_driver *drv)
int err = -ENOMEM;
int i;
- twidjoy = kzalloc(sizeof(*twidjoy), GFP_KERNEL);
+ twidjoy = kzalloc_obj(*twidjoy, GFP_KERNEL);
input_dev = input_allocate_device();
if (!twidjoy || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index ebeab441e9ec..45027058a777 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -124,7 +124,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- warrior = kzalloc(sizeof(*warrior), GFP_KERNEL);
+ warrior = kzalloc_obj(*warrior, GFP_KERNEL);
input_dev = input_allocate_device();
if (!warrior || !input_dev)
goto fail1;
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 363d50949386..58ff39dee70c 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1744,7 +1744,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W)
return 0;
- xpad->led = led = kzalloc(sizeof(*led), GFP_KERNEL);
+ xpad->led = led = kzalloc_obj(*led, GFP_KERNEL);
if (!led)
return -ENOMEM;
@@ -2077,7 +2077,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
break;
}
- xpad = kzalloc(sizeof(*xpad), GFP_KERNEL);
+ xpad = kzalloc_obj(*xpad, GFP_KERNEL);
if (!xpad)
return -ENOMEM;
diff --git a/drivers/input/joystick/zhenhua.c b/drivers/input/joystick/zhenhua.c
index cc0e2a77ac5e..873e71fe6580 100644
--- a/drivers/input/joystick/zhenhua.c
+++ b/drivers/input/joystick/zhenhua.c
@@ -131,7 +131,7 @@ static int zhenhua_connect(struct serio *serio, struct serio_driver *drv)
struct input_dev *input_dev;
int err = -ENOMEM;
- zhenhua = kzalloc(sizeof(*zhenhua), GFP_KERNEL);
+ zhenhua = kzalloc_obj(*zhenhua, GFP_KERNEL);
input_dev = input_allocate_device();
if (!zhenhua || !input_dev)
goto fail1;