Linux clock framework development
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: claudiu.beznea@microchip.com
Cc: linux-clk@vger.kernel.org
Subject: [bug report] clk: at91: clk-sam9x60-pll: re-factor to support plls with multiple outputs
Date: Mon, 27 Feb 2023 10:37:53 +0300	[thread overview]
Message-ID: <Y/xd0XWhhp/bBkwY@kili> (raw)

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

                 reply	other threads:[~2023-02-27  7:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y/xd0XWhhp/bBkwY@kili \
    --to=error27@gmail.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=linux-clk@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox