* [bug report] clk: at91: clk-sam9x60-pll: re-factor to support plls with multiple outputs
@ 2023-02-27 7:37 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-02-27 7:37 UTC (permalink / raw)
To: claudiu.beznea; +Cc: linux-clk
Hello Claudiu Beznea,
The patch 43b1bb4a9b3e: "clk: at91: clk-sam9x60-pll: re-factor to
support plls with multiple outputs" from Jul 22, 2020, leads to the
following Smatch static checker warning:
drivers/clk/at91/clk-sam9x60-pll.c:672 sam9x60_clk_register_frac_pll()
warn: passing zero to 'ERR_PTR'
drivers/clk/at91/clk-sam9x60-pll.c
663 parent_rate = clk_hw_get_rate(parent_hw);
664 if (!parent_rate) {
665 hw = ERR_PTR(-EINVAL);
666 goto free;
667 }
668
669 ret = sam9x60_frac_pll_compute_mul_frac(&frac->core, FCORE_MIN,
670 parent_rate, true);
671 if (ret <= 0) {
^^^^^^^^
--> 672 hw = ERR_PTR(ret);
^^^^^^^^^^^^^^^^^
ret can't be zero. I don't know how this is called, but my guess is
that if "ret" were zero then "hw" would be NULL and that results in a
NULL dereference in the caller.
673 goto free;
674 }
675 }
676 spin_unlock_irqrestore(frac->core.lock, irqflags);
677
678 hw = &frac->core.hw;
679 ret = clk_hw_register(NULL, hw);
680 if (ret) {
681 kfree(frac);
682 hw = ERR_PTR(ret);
683 }
684
685 return hw;
686
687 free:
688 spin_unlock_irqrestore(frac->core.lock, irqflags);
689 kfree(frac);
690 return hw;
691 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-27 7:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-27 7:37 [bug report] clk: at91: clk-sam9x60-pll: re-factor to support plls with multiple outputs Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox