linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: "Heiko Stübner" <heiko@sntech.de>,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Cc: Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Aditya Pakki <pakki001@umn.edu>,
	Kangjie Lu <kjlu@umn.edu>, Navid Emamdoost <emamd001@umn.edu>,
	Stephen McCamant <smccaman@umn.edu>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: clk: rockchip: Checking a kmemdup() call in rockchip_clk_register_pll()
Date: Mon, 14 Oct 2019 09:26:41 +0200	[thread overview]
Message-ID: <45588ab8-2a6c-3f29-61ff-bccf8d6fb291@web.de> (raw)
In-Reply-To: <2588953.0pqkEXWxhN@phil>

> The other option would be to panic, but the kernel should not
> panic if other options are available - and continuing with a static
> pll frequency is less invasive in the error case.

I would like to point out that this function implementation contains
the following source code already.

…
	/* name the actual pll */
	snprintf(pll_name, sizeof(pll_name), "pll_%s", name);

	pll = kzalloc(sizeof(*pll), GFP_KERNEL);
	if (!pll)
		return ERR_PTR(-ENOMEM);
…



…
> +++ b/drivers/clk/rockchip/clk-pll.c
> @@ -909,14 +909,16 @@ struct clk *rockchip_clk_register_pll(struct rockchip_clk_provider *ctx,
> -		pll->rate_count = len;
>  		pll->rate_table = kmemdup(rate_table,
>  					pll->rate_count *
>  					sizeof(struct rockchip_pll_rate_table),
>  					GFP_KERNEL);
> -		WARN(!pll->rate_table,
> -			"%s: could not allocate rate table for %s\n",
> -			__func__, name);
> +
> +		/*
> +		 * Set num rates to 0 if kmemdup fails. That way the clock
> +		 * at least can report its rate and stays usable.
> +		 */
> +		pll->rate_count = pll->rate_table ? len : 0;

Can an other error handling strategy make sense occasionally?

…
		if (!pll->rate_table) {
			clk_unregister(mux_clk);
			mux_clk = ERR_PTR(-ENOMEM);
			goto err_mux;
		}
…


Would you like to adjust such exception handling another bit?

Regards,
Markus

  reply	other threads:[~2019-10-14  7:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-12 13:55 clk: rockchip: Checking a kmemdup() call in rockchip_clk_register_pll() Markus Elfring
2019-10-12 21:32 ` Heiko Stübner
2019-10-13  8:45   ` Markus Elfring
2019-10-13 21:49     ` Heiko Stuebner
2019-10-14  7:26       ` Markus Elfring [this message]
2019-10-15 20:29         ` Heiko Stuebner
2019-10-16  6:24           ` Markus Elfring

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=45588ab8-2a6c-3f29-61ff-bccf8d6fb291@web.de \
    --to=markus.elfring@web.de \
    --cc=emamd001@umn.edu \
    --cc=heiko@sntech.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kjlu@umn.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=pakki001@umn.edu \
    --cc=sboyd@kernel.org \
    --cc=smccaman@umn.edu \
    /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;
as well as URLs for NNTP newsgroup(s).