MLK-20202 clocksource: imx-gpt: fix coverity issues
This patch fixes coverity issues as below: 1. resource leak 2. possible case of division by zero. Fix #1 by kfree the resource before return error; Fix #2 by adding zero check before registering delay timer. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Reviewed-by: Bai Ping <ping.bai@nxp.com>pull/10/head
parent
55ce109b28
commit
944d53a2b7
|
@ -171,6 +171,9 @@ static int __init mxc_clocksource_init(struct imx_timer *imxtm)
|
|||
unsigned int c = clk_get_rate(imxtm->clk_per);
|
||||
void __iomem *reg = imxtm->base + imxtm->gpt->reg_tcn;
|
||||
|
||||
if (c == 0)
|
||||
return -EINVAL;
|
||||
|
||||
#ifndef CONFIG_ARM64
|
||||
imx_delay_timer.read_current_timer = &imx_read_current_timer;
|
||||
imx_delay_timer.freq = c;
|
||||
|
@ -493,12 +496,16 @@ static int __init mxc_timer_init_dt(struct device_node *np, enum imx_gpt_type t
|
|||
return -ENOMEM;
|
||||
|
||||
imxtm->base = of_iomap(np, 0);
|
||||
if (!imxtm->base)
|
||||
if (!imxtm->base) {
|
||||
kfree(imxtm);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
imxtm->irq = irq_of_parse_and_map(np, 0);
|
||||
if (imxtm->irq <= 0)
|
||||
if (imxtm->irq <= 0) {
|
||||
kfree(imxtm);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
imxtm->clk_ipg = of_clk_get_by_name(np, "ipg");
|
||||
|
||||
|
|
Loading…
Reference in New Issue