summaryrefslogtreecommitdiff
path: root/drivers/watchdog
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/watchdog
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/watchdog')
-rw-r--r--drivers/watchdog/exar_wdt.c2
-rw-r--r--drivers/watchdog/mei_wdt.c2
-rw-r--r--drivers/watchdog/pcwd_usb.c2
-rw-r--r--drivers/watchdog/watchdog_dev.c2
-rw-r--r--drivers/watchdog/watchdog_pretimeout.c4
5 files changed, 6 insertions, 6 deletions
diff --git a/drivers/watchdog/exar_wdt.c b/drivers/watchdog/exar_wdt.c
index c2e3bb08df89..30fa33a4c08d 100644
--- a/drivers/watchdog/exar_wdt.c
+++ b/drivers/watchdog/exar_wdt.c
@@ -342,7 +342,7 @@ static int __init exar_wdt_register(struct wdt_priv *priv, const int idx)
{
struct wdt_pdev_node *n;
- n = kzalloc(sizeof(*n), GFP_KERNEL);
+ n = kzalloc_obj(*n, GFP_KERNEL);
if (!n)
return -ENOMEM;
diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c
index c7a7235e6224..01c44881608c 100644
--- a/drivers/watchdog/mei_wdt.c
+++ b/drivers/watchdog/mei_wdt.c
@@ -563,7 +563,7 @@ static int mei_wdt_probe(struct mei_cl_device *cldev,
struct mei_wdt *wdt;
int ret;
- wdt = kzalloc(sizeof(struct mei_wdt), GFP_KERNEL);
+ wdt = kzalloc_obj(struct mei_wdt, GFP_KERNEL);
if (!wdt)
return -ENOMEM;
diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index b636650b714b..dbefe9a690d7 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -641,7 +641,7 @@ static int usb_pcwd_probe(struct usb_interface *interface,
pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
/* allocate memory for our device and initialize it */
- usb_pcwd = kzalloc(sizeof(struct usb_pcwd_private), GFP_KERNEL);
+ usb_pcwd = kzalloc_obj(struct usb_pcwd_private, GFP_KERNEL);
if (usb_pcwd == NULL)
goto error;
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 9a5e544b886b..cd4c7342a172 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -1019,7 +1019,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd)
struct watchdog_core_data *wd_data;
int err;
- wd_data = kzalloc(sizeof(struct watchdog_core_data), GFP_KERNEL);
+ wd_data = kzalloc_obj(struct watchdog_core_data, GFP_KERNEL);
if (!wd_data)
return -ENOMEM;
mutex_init(&wd_data->lock);
diff --git a/drivers/watchdog/watchdog_pretimeout.c b/drivers/watchdog/watchdog_pretimeout.c
index 2526436dc74d..3957b6ba63b7 100644
--- a/drivers/watchdog/watchdog_pretimeout.c
+++ b/drivers/watchdog/watchdog_pretimeout.c
@@ -119,7 +119,7 @@ int watchdog_register_governor(struct watchdog_governor *gov)
struct watchdog_pretimeout *p;
struct governor_priv *priv;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -183,7 +183,7 @@ int watchdog_register_pretimeout(struct watchdog_device *wdd)
if (!watchdog_have_pretimeout(wdd))
return 0;
- p = kzalloc(sizeof(*p), GFP_KERNEL);
+ p = kzalloc_obj(*p, GFP_KERNEL);
if (!p)
return -ENOMEM;