mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
To: cgel.zte@gmail.com
Cc: alim.akhtar@samsung.com, chi.minghao@zte.com.cn,
	cw00.choi@samsung.com, linux-arm-kernel@lists.infradead.org,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, mturquette@baylibre.com,
	s.nawrocki@samsung.com, sboyd@kernel.org, tomasz.figa@gmail.com,
	zealci@zte.com.cn
Subject: Re: [PATCH] clk/samsung: Use of_device_get_match_data()
Date: Fri, 4 Mar 2022 08:07:57 +0100	[thread overview]
Message-ID: <887c5cf8-8dda-3311-0aa7-27fbceb6a6f9@canonical.com> (raw)
In-Reply-To: <20220304011155.2061393-1-chi.minghao@zte.com.cn>

On 04/03/2022 02:11, cgel.zte@gmail.com wrote:
> From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> 
> Use of_device_get_match_data() to simplify the code.
> 
> Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> ---
>  drivers/clk/samsung/clk-exynos-clkout.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c
> index e6d6cbf8c4e6..feed1a347c09 100644
> --- a/drivers/clk/samsung/clk-exynos-clkout.c
> +++ b/drivers/clk/samsung/clk-exynos-clkout.c
> @@ -81,19 +81,13 @@ MODULE_DEVICE_TABLE(of, exynos_clkout_ids);
>  static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask)
>  {
>  	const struct exynos_clkout_variant *variant;
> -	const struct of_device_id *match;
>  
>  	if (!dev->parent) {
>  		dev_err(dev, "not instantiated from MFD\n");
>  		return -EINVAL;
>  	}
>  
> -	match = of_match_device(exynos_clkout_ids, dev->parent);
> -	if (!match) {
> -		dev_err(dev, "cannot match parent device\n");
> -		return -EINVAL;
> -	}
> -	variant = match->data;
> +	variant = of_device_get_match_data(dev->parent);
>  

What about possible NULL pointer exception? Device is being instantiated
by MFD, so the match here could be false if MFD driver is updated but
this one here not. With your change returned NULL will be dereferenced
line below.

>  	*mux_mask = variant->mux_mask;
>  


Best regards,
Krzysztof

      reply	other threads:[~2022-03-04  7:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  9:22 cgel.zte
2022-03-03  9:37 ` Krzysztof Kozlowski
2022-03-04  1:11   ` cgel.zte
2022-03-04  7:07     ` Krzysztof Kozlowski [this message]

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=887c5cf8-8dda-3311-0aa7-27fbceb6a6f9@canonical.com \
    --to=krzysztof.kozlowski@canonical.com \
    --cc=alim.akhtar@samsung.com \
    --cc=cgel.zte@gmail.com \
    --cc=chi.minghao@zte.com.cn \
    --cc=cw00.choi@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=s.nawrocki@samsung.com \
    --cc=sboyd@kernel.org \
    --cc=tomasz.figa@gmail.com \
    --cc=zealci@zte.com.cn \
    /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

all inboxes | Powered by JetHome®