summaryrefslogtreecommitdiff
path: root/drivers/clocksource
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/clocksource
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/clocksource')
-rw-r--r--drivers/clocksource/bcm2835_timer.c2
-rw-r--r--drivers/clocksource/clps711x-timer.c2
-rw-r--r--drivers/clocksource/dw_apb_timer.c6
-rw-r--r--drivers/clocksource/ingenic-sysost.c8
-rw-r--r--drivers/clocksource/ingenic-timer.c3
-rw-r--r--drivers/clocksource/mmio.c2
-rw-r--r--drivers/clocksource/mps2-timer.c2
-rw-r--r--drivers/clocksource/renesas-ostm.c2
-rw-r--r--drivers/clocksource/sh_cmt.c6
-rw-r--r--drivers/clocksource/sh_mtu2.c6
-rw-r--r--drivers/clocksource/sh_tmu.c6
-rw-r--r--drivers/clocksource/timer-atmel-pit.c2
-rw-r--r--drivers/clocksource/timer-cadence-ttc.c4
-rw-r--r--drivers/clocksource/timer-davinci.c2
-rw-r--r--drivers/clocksource/timer-ep93xx.c2
-rw-r--r--drivers/clocksource/timer-fsl-ftm.c2
-rw-r--r--drivers/clocksource/timer-fttmr010.c2
-rw-r--r--drivers/clocksource/timer-goldfish.c2
-rw-r--r--drivers/clocksource/timer-gxp.c2
-rw-r--r--drivers/clocksource/timer-imx-gpt.c2
-rw-r--r--drivers/clocksource/timer-imx-sysctr.c2
-rw-r--r--drivers/clocksource/timer-ixp4xx.c2
-rw-r--r--drivers/clocksource/timer-microchip-pit64b.c4
-rw-r--r--drivers/clocksource/timer-msc313e.c2
-rw-r--r--drivers/clocksource/timer-nxp-pit.c2
-rw-r--r--drivers/clocksource/timer-rockchip.c4
-rw-r--r--drivers/clocksource/timer-stm32.c5
-rw-r--r--drivers/clocksource/timer-ti-dm-systimer.c4
-rw-r--r--drivers/clocksource/timer-zevio.c2
29 files changed, 45 insertions, 47 deletions
diff --git a/drivers/clocksource/bcm2835_timer.c b/drivers/clocksource/bcm2835_timer.c
index 319c0c780a15..ff0e21edd9c1 100644
--- a/drivers/clocksource/bcm2835_timer.c
+++ b/drivers/clocksource/bcm2835_timer.c
@@ -98,7 +98,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
goto err_iounmap;
}
- timer = kzalloc(sizeof(*timer), GFP_KERNEL);
+ timer = kzalloc_obj(*timer, GFP_KERNEL);
if (!timer) {
ret = -ENOMEM;
goto err_iounmap;
diff --git a/drivers/clocksource/clps711x-timer.c b/drivers/clocksource/clps711x-timer.c
index bbceb0289d45..75c17eeef689 100644
--- a/drivers/clocksource/clps711x-timer.c
+++ b/drivers/clocksource/clps711x-timer.c
@@ -54,7 +54,7 @@ static int __init _clps711x_clkevt_init(struct clk *clock, void __iomem *base,
struct clock_event_device *clkevt;
unsigned long rate;
- clkevt = kzalloc(sizeof(*clkevt), GFP_KERNEL);
+ clkevt = kzalloc_obj(*clkevt, GFP_KERNEL);
if (!clkevt)
return -ENOMEM;
diff --git a/drivers/clocksource/dw_apb_timer.c b/drivers/clocksource/dw_apb_timer.c
index 3a55ae5fe225..043793728e23 100644
--- a/drivers/clocksource/dw_apb_timer.c
+++ b/drivers/clocksource/dw_apb_timer.c
@@ -222,8 +222,8 @@ struct dw_apb_clock_event_device *
dw_apb_clockevent_init(int cpu, const char *name, unsigned rating,
void __iomem *base, int irq, unsigned long freq)
{
- struct dw_apb_clock_event_device *dw_ced =
- kzalloc(sizeof(*dw_ced), GFP_KERNEL);
+ struct dw_apb_clock_event_device *dw_ced = kzalloc_obj(*dw_ced,
+ GFP_KERNEL);
int err;
if (!dw_ced)
@@ -340,7 +340,7 @@ struct dw_apb_clocksource *
dw_apb_clocksource_init(unsigned rating, const char *name, void __iomem *base,
unsigned long freq)
{
- struct dw_apb_clocksource *dw_cs = kzalloc(sizeof(*dw_cs), GFP_KERNEL);
+ struct dw_apb_clocksource *dw_cs = kzalloc_obj(*dw_cs, GFP_KERNEL);
if (!dw_cs)
return NULL;
diff --git a/drivers/clocksource/ingenic-sysost.c b/drivers/clocksource/ingenic-sysost.c
index e79cfb0b8e05..22caa69197a2 100644
--- a/drivers/clocksource/ingenic-sysost.c
+++ b/drivers/clocksource/ingenic-sysost.c
@@ -279,7 +279,7 @@ static int __init ingenic_ost_register_clock(struct ingenic_ost *ost,
struct ingenic_ost_clk *ost_clk;
int val, err;
- ost_clk = kzalloc(sizeof(*ost_clk), GFP_KERNEL);
+ ost_clk = kzalloc_obj(*ost_clk, GFP_KERNEL);
if (!ost_clk)
return -ENOMEM;
@@ -432,7 +432,7 @@ static int __init ingenic_ost_probe(struct device_node *np)
unsigned int i;
int ret;
- ost = kzalloc(sizeof(*ost), GFP_KERNEL);
+ ost = kzalloc_obj(*ost, GFP_KERNEL);
if (!ost)
return -ENOMEM;
@@ -458,8 +458,8 @@ static int __init ingenic_ost_probe(struct device_node *np)
ost->soc_info = id->data;
- ost->clocks = kzalloc(struct_size(ost->clocks, hws, ost->soc_info->num_channels),
- GFP_KERNEL);
+ ost->clocks = kzalloc_flex(*ost->clocks, hws,
+ ost->soc_info->num_channels, GFP_KERNEL);
if (!ost->clocks) {
ret = -ENOMEM;
goto err_clk_disable;
diff --git a/drivers/clocksource/ingenic-timer.c b/drivers/clocksource/ingenic-timer.c
index 154ee5f7954a..3c545cb756af 100644
--- a/drivers/clocksource/ingenic-timer.c
+++ b/drivers/clocksource/ingenic-timer.c
@@ -286,8 +286,7 @@ static int __init ingenic_tcu_init(struct device_node *np)
if (IS_ERR(map))
return PTR_ERR(map);
- tcu = kzalloc(struct_size(tcu, timers, num_possible_cpus()),
- GFP_KERNEL);
+ tcu = kzalloc_flex(*tcu, timers, num_possible_cpus(), GFP_KERNEL);
if (!tcu)
return -ENOMEM;
diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
index 9de751531831..286513486542 100644
--- a/drivers/clocksource/mmio.c
+++ b/drivers/clocksource/mmio.c
@@ -55,7 +55,7 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name,
if (bits > 64 || bits < 16)
return -EINVAL;
- cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
+ cs = kzalloc_obj(struct clocksource_mmio, GFP_KERNEL);
if (!cs)
return -ENOMEM;
diff --git a/drivers/clocksource/mps2-timer.c b/drivers/clocksource/mps2-timer.c
index efe8cad8f2a5..53c484d29195 100644
--- a/drivers/clocksource/mps2-timer.c
+++ b/drivers/clocksource/mps2-timer.c
@@ -136,7 +136,7 @@ static int __init mps2_clockevent_init(struct device_node *np)
goto out_iounmap;
}
- ce = kzalloc(sizeof(*ce), GFP_KERNEL);
+ ce = kzalloc_obj(*ce, GFP_KERNEL);
if (!ce) {
ret = -ENOMEM;
goto out_iounmap;
diff --git a/drivers/clocksource/renesas-ostm.c b/drivers/clocksource/renesas-ostm.c
index 2089aeaae225..36132692bae5 100644
--- a/drivers/clocksource/renesas-ostm.c
+++ b/drivers/clocksource/renesas-ostm.c
@@ -165,7 +165,7 @@ static int __init ostm_init(struct device_node *np)
struct timer_of *to;
int ret;
- to = kzalloc(sizeof(*to), GFP_KERNEL);
+ to = kzalloc_obj(*to, GFP_KERNEL);
if (!to)
return -ENOMEM;
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 791b298c995b..fd8cdabef9bc 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -1084,8 +1084,8 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
/* Allocate and setup the channels. */
cmt->num_channels = hweight8(cmt->hw_channels);
- cmt->channels = kcalloc(cmt->num_channels, sizeof(*cmt->channels),
- GFP_KERNEL);
+ cmt->channels = kzalloc_objs(*cmt->channels, cmt->num_channels,
+ GFP_KERNEL);
if (cmt->channels == NULL) {
ret = -ENOMEM;
goto err_unmap;
@@ -1139,7 +1139,7 @@ static int sh_cmt_probe(struct platform_device *pdev)
goto out;
}
- cmt = kzalloc(sizeof(*cmt), GFP_KERNEL);
+ cmt = kzalloc_obj(*cmt, GFP_KERNEL);
if (cmt == NULL)
return -ENOMEM;
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c
index 34872df5458a..333548989ed5 100644
--- a/drivers/clocksource/sh_mtu2.c
+++ b/drivers/clocksource/sh_mtu2.c
@@ -420,8 +420,8 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
mtu->num_channels = min_t(unsigned int, ret,
ARRAY_SIZE(sh_mtu2_channel_offsets));
- mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
- GFP_KERNEL);
+ mtu->channels = kzalloc_objs(*mtu->channels, mtu->num_channels,
+ GFP_KERNEL);
if (mtu->channels == NULL) {
ret = -ENOMEM;
goto err_unmap;
@@ -462,7 +462,7 @@ static int sh_mtu2_probe(struct platform_device *pdev)
goto out;
}
- mtu = kzalloc(sizeof(*mtu), GFP_KERNEL);
+ mtu = kzalloc_obj(*mtu, GFP_KERNEL);
if (mtu == NULL)
return -ENOMEM;
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c
index 3fc6ed9b5630..365739e1fbad 100644
--- a/drivers/clocksource/sh_tmu.c
+++ b/drivers/clocksource/sh_tmu.c
@@ -546,8 +546,8 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
}
/* Allocate and setup the channels. */
- tmu->channels = kcalloc(tmu->num_channels, sizeof(*tmu->channels),
- GFP_KERNEL);
+ tmu->channels = kzalloc_objs(*tmu->channels, tmu->num_channels,
+ GFP_KERNEL);
if (tmu->channels == NULL) {
ret = -ENOMEM;
goto err_unmap;
@@ -593,7 +593,7 @@ static int sh_tmu_probe(struct platform_device *pdev)
goto out;
}
- tmu = kzalloc(sizeof(*tmu), GFP_KERNEL);
+ tmu = kzalloc_obj(*tmu, GFP_KERNEL);
if (tmu == NULL)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
index b4f264ed1937..253c3e4d0296 100644
--- a/drivers/clocksource/timer-atmel-pit.c
+++ b/drivers/clocksource/timer-atmel-pit.c
@@ -170,7 +170,7 @@ static int __init at91sam926x_pit_dt_init(struct device_node *node)
int ret;
struct pit_data *data;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c
index b8a1cf59b9d6..836141e51118 100644
--- a/drivers/clocksource/timer-cadence-ttc.c
+++ b/drivers/clocksource/timer-cadence-ttc.c
@@ -334,7 +334,7 @@ static int __init ttc_setup_clocksource(struct clk *clk, void __iomem *base,
struct ttc_timer_clocksource *ttccs;
int err;
- ttccs = kzalloc(sizeof(*ttccs), GFP_KERNEL);
+ ttccs = kzalloc_obj(*ttccs, GFP_KERNEL);
if (!ttccs)
return -ENOMEM;
@@ -417,7 +417,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,
struct ttc_timer_clockevent *ttcce;
int err;
- ttcce = kzalloc(sizeof(*ttcce), GFP_KERNEL);
+ ttcce = kzalloc_obj(*ttcce, GFP_KERNEL);
if (!ttcce)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-davinci.c b/drivers/clocksource/timer-davinci.c
index b1c248498be4..9bf1728a87dc 100644
--- a/drivers/clocksource/timer-davinci.c
+++ b/drivers/clocksource/timer-davinci.c
@@ -271,7 +271,7 @@ int __init davinci_timer_register(struct clk *clk,
davinci_timer_init(base);
tick_rate = clk_get_rate(clk);
- clockevent = kzalloc(sizeof(*clockevent), GFP_KERNEL);
+ clockevent = kzalloc_obj(*clockevent, GFP_KERNEL);
if (!clockevent) {
rv = -ENOMEM;
goto exit_iounmap_base;
diff --git a/drivers/clocksource/timer-ep93xx.c b/drivers/clocksource/timer-ep93xx.c
index 6981ff3ac8a9..04eeda15d997 100644
--- a/drivers/clocksource/timer-ep93xx.c
+++ b/drivers/clocksource/timer-ep93xx.c
@@ -141,7 +141,7 @@ static int __init ep93xx_timer_of_init(struct device_node *np)
struct ep93xx_tcu *tcu;
int ret;
- tcu = kzalloc(sizeof(*tcu), GFP_KERNEL);
+ tcu = kzalloc_obj(*tcu, GFP_KERNEL);
if (!tcu)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-fsl-ftm.c b/drivers/clocksource/timer-fsl-ftm.c
index 93f336ec875a..df82307e690c 100644
--- a/drivers/clocksource/timer-fsl-ftm.c
+++ b/drivers/clocksource/timer-fsl-ftm.c
@@ -300,7 +300,7 @@ static int __init ftm_timer_init(struct device_node *np)
unsigned long freq;
int ret, irq;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c
index 126fb1f259b2..e0f7d5976518 100644
--- a/drivers/clocksource/timer-fttmr010.c
+++ b/drivers/clocksource/timer-fttmr010.c
@@ -295,7 +295,7 @@ static int __init fttmr010_common_init(struct device_node *np,
return ret;
}
- fttmr010 = kzalloc(sizeof(*fttmr010), GFP_KERNEL);
+ fttmr010 = kzalloc_obj(*fttmr010, GFP_KERNEL);
if (!fttmr010) {
ret = -ENOMEM;
goto out_disable_clock;
diff --git a/drivers/clocksource/timer-goldfish.c b/drivers/clocksource/timer-goldfish.c
index 0512d5eabc82..60982561e8b6 100644
--- a/drivers/clocksource/timer-goldfish.c
+++ b/drivers/clocksource/timer-goldfish.c
@@ -102,7 +102,7 @@ int __init goldfish_timer_init(int irq, void __iomem *base)
struct goldfish_timer *timerdrv;
int ret;
- timerdrv = kzalloc(sizeof(*timerdrv), GFP_KERNEL);
+ timerdrv = kzalloc_obj(*timerdrv, GFP_KERNEL);
if (!timerdrv)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-gxp.c b/drivers/clocksource/timer-gxp.c
index 48a73c101eb8..7442e9bdd0d5 100644
--- a/drivers/clocksource/timer-gxp.c
+++ b/drivers/clocksource/timer-gxp.c
@@ -76,7 +76,7 @@ static int __init gxp_timer_init(struct device_node *node)
u32 freq;
int ret, irq;
- gxp_timer = kzalloc(sizeof(*gxp_timer), GFP_KERNEL);
+ gxp_timer = kzalloc_obj(*gxp_timer, GFP_KERNEL);
if (!gxp_timer) {
ret = -ENOMEM;
pr_err("Can't allocate gxp_timer");
diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
index 489e69169ed4..ad310be44cb6 100644
--- a/drivers/clocksource/timer-imx-gpt.c
+++ b/drivers/clocksource/timer-imx-gpt.c
@@ -428,7 +428,7 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
if (initialized)
return 0;
- imxtm = kzalloc(sizeof(*imxtm), GFP_KERNEL);
+ imxtm = kzalloc_obj(*imxtm, GFP_KERNEL);
if (!imxtm)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-imx-sysctr.c b/drivers/clocksource/timer-imx-sysctr.c
index 44525813be1e..5eb3b3c6d0ad 100644
--- a/drivers/clocksource/timer-imx-sysctr.c
+++ b/drivers/clocksource/timer-imx-sysctr.c
@@ -139,7 +139,7 @@ static int __init __sysctr_timer_init(struct device_node *np)
void __iomem *base;
int ret;
- priv = kzalloc(sizeof(struct sysctr_private), GFP_KERNEL);
+ priv = kzalloc_obj(struct sysctr_private, GFP_KERNEL);
if (!priv)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-ixp4xx.c b/drivers/clocksource/timer-ixp4xx.c
index 720ed70a2964..42f679b1165b 100644
--- a/drivers/clocksource/timer-ixp4xx.c
+++ b/drivers/clocksource/timer-ixp4xx.c
@@ -166,7 +166,7 @@ static __init int ixp4xx_timer_register(void __iomem *base,
struct ixp4xx_timer *tmr;
int ret;
- tmr = kzalloc(sizeof(*tmr), GFP_KERNEL);
+ tmr = kzalloc_obj(*tmr, GFP_KERNEL);
if (!tmr)
return -ENOMEM;
tmr->base = base;
diff --git a/drivers/clocksource/timer-microchip-pit64b.c b/drivers/clocksource/timer-microchip-pit64b.c
index 57209bb38c70..d54a1c91781f 100644
--- a/drivers/clocksource/timer-microchip-pit64b.c
+++ b/drivers/clocksource/timer-microchip-pit64b.c
@@ -350,7 +350,7 @@ static int __init mchp_pit64b_init_clksrc(struct mchp_pit64b_timer *timer,
struct mchp_pit64b_clksrc *cs;
int ret;
- cs = kzalloc(sizeof(*cs), GFP_KERNEL);
+ cs = kzalloc_obj(*cs, GFP_KERNEL);
if (!cs)
return -ENOMEM;
@@ -397,7 +397,7 @@ static int __init mchp_pit64b_init_clkevt(struct mchp_pit64b_timer *timer,
struct mchp_pit64b_clkevt *ce;
int ret;
- ce = kzalloc(sizeof(*ce), GFP_KERNEL);
+ ce = kzalloc_obj(*ce, GFP_KERNEL);
if (!ce)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-msc313e.c b/drivers/clocksource/timer-msc313e.c
index 54c54ca7c786..33822f0bc339 100644
--- a/drivers/clocksource/timer-msc313e.c
+++ b/drivers/clocksource/timer-msc313e.c
@@ -171,7 +171,7 @@ static int __init msc313e_clkevt_init(struct device_node *np)
int ret;
struct timer_of *to;
- to = kzalloc(sizeof(*to), GFP_KERNEL);
+ to = kzalloc_obj(*to, GFP_KERNEL);
if (!to)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-nxp-pit.c b/drivers/clocksource/timer-nxp-pit.c
index d1740f18f718..9109dedab08c 100644
--- a/drivers/clocksource/timer-nxp-pit.c
+++ b/drivers/clocksource/timer-nxp-pit.c
@@ -276,7 +276,7 @@ static int pit_timer_init(struct device_node *np)
unsigned long clk_rate;
int irq, ret;
- pit = kzalloc(sizeof(*pit), GFP_KERNEL);
+ pit = kzalloc_obj(*pit, GFP_KERNEL);
if (!pit)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-rockchip.c b/drivers/clocksource/timer-rockchip.c
index 1f95d0aca08f..c866127ee1e5 100644
--- a/drivers/clocksource/timer-rockchip.c
+++ b/drivers/clocksource/timer-rockchip.c
@@ -207,7 +207,7 @@ static int __init rk_clkevt_init(struct device_node *np)
struct clock_event_device *ce;
int ret = -EINVAL;
- rk_clkevt = kzalloc(sizeof(struct rk_clkevt), GFP_KERNEL);
+ rk_clkevt = kzalloc_obj(struct rk_clkevt, GFP_KERNEL);
if (!rk_clkevt) {
ret = -ENOMEM;
goto out;
@@ -254,7 +254,7 @@ static int __init rk_clksrc_init(struct device_node *np)
{
int ret = -EINVAL;
- rk_clksrc = kzalloc(sizeof(struct rk_timer), GFP_KERNEL);
+ rk_clksrc = kzalloc_obj(struct rk_timer, GFP_KERNEL);
if (!rk_clksrc) {
ret = -ENOMEM;
goto out;
diff --git a/drivers/clocksource/timer-stm32.c b/drivers/clocksource/timer-stm32.c
index 0a4ea3288bfb..4a0f06a419d7 100644
--- a/drivers/clocksource/timer-stm32.c
+++ b/drivers/clocksource/timer-stm32.c
@@ -291,7 +291,7 @@ static int __init stm32_timer_init(struct device_node *node)
struct timer_of *to;
int ret;
- to = kzalloc(sizeof(*to), GFP_KERNEL);
+ to = kzalloc_obj(*to, GFP_KERNEL);
if (!to)
return -ENOMEM;
@@ -302,8 +302,7 @@ static int __init stm32_timer_init(struct device_node *node)
if (ret)
goto err;
- to->private_data = kzalloc(sizeof(struct stm32_timer_private),
- GFP_KERNEL);
+ to->private_data = kzalloc_obj(struct stm32_timer_private, GFP_KERNEL);
if (!to->private_data) {
ret = -ENOMEM;
goto deinit;
diff --git a/drivers/clocksource/timer-ti-dm-systimer.c b/drivers/clocksource/timer-ti-dm-systimer.c
index 985a6d08512b..3bffd7198a38 100644
--- a/drivers/clocksource/timer-ti-dm-systimer.c
+++ b/drivers/clocksource/timer-ti-dm-systimer.c
@@ -600,7 +600,7 @@ static int __init dmtimer_clockevent_init(struct device_node *np)
struct dmtimer_clockevent *clkevt;
int error;
- clkevt = kzalloc(sizeof(*clkevt), GFP_KERNEL);
+ clkevt = kzalloc_obj(*clkevt, GFP_KERNEL);
if (!clkevt)
return -ENOMEM;
@@ -757,7 +757,7 @@ static int __init dmtimer_clocksource_init(struct device_node *np)
struct clocksource *dev;
int error;
- clksrc = kzalloc(sizeof(*clksrc), GFP_KERNEL);
+ clksrc = kzalloc_obj(*clksrc, GFP_KERNEL);
if (!clksrc)
return -ENOMEM;
diff --git a/drivers/clocksource/timer-zevio.c b/drivers/clocksource/timer-zevio.c
index ecaa3568841c..db1ba9b2c2c9 100644
--- a/drivers/clocksource/timer-zevio.c
+++ b/drivers/clocksource/timer-zevio.c
@@ -119,7 +119,7 @@ static int __init zevio_timer_add(struct device_node *node)
struct resource res;
int irqnr, ret;
- timer = kzalloc(sizeof(*timer), GFP_KERNEL);
+ timer = kzalloc_obj(*timer, GFP_KERNEL);
if (!timer)
return -ENOMEM;