linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Heiko Stübner" <heiko@sntech.de>
To: cgel.zte@gmail.com, mturquette@baylibre.com,
	Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	Minghao Chi <chi.minghao@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] clk/rockchip: Use of_device_get_match_data()
Date: Thu, 10 Mar 2022 17:22:15 +0100	[thread overview]
Message-ID: <2697395.DCgNgQjydf@diego> (raw)
In-Reply-To: <20220309185738.2192EC340EC@smtp.kernel.org>

Am Mittwoch, 9. März 2022, 19:57:36 CET schrieb Stephen Boyd:
> Quoting cgel.zte@gmail.com (2022-03-03 17:17:03)
> > From: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> > 
> > Use of_device_get_match_data() to simplify the code.
> > 
> > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
> > ---
> >  drivers/clk/rockchip/clk-rk3399.c | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/drivers/clk/rockchip/clk-rk3399.c b/drivers/clk/rockchip/clk-rk3399.c
> > index 306910a3a0d3..b1b67bfb63b8 100644
> > --- a/drivers/clk/rockchip/clk-rk3399.c
> > +++ b/drivers/clk/rockchip/clk-rk3399.c
> > @@ -1634,14 +1634,8 @@ static const struct of_device_id clk_rk3399_match_table[] = {
> >  static int __init clk_rk3399_probe(struct platform_device *pdev)
> >  {
> >         struct device_node *np = pdev->dev.of_node;
> > -       const struct of_device_id *match;
> >         const struct clk_rk3399_inits *init_data;
> > -
> > -       match = of_match_device(clk_rk3399_match_table, &pdev->dev);
> > -       if (!match || !match->data)
> > -               return -EINVAL;
> > -
> > -       init_data = match->data;
> > +       init_data = of_device_get_match_data(&pdev->dev);
> 
> The translation doesn't look equivalent. Before we would bail out of
> probe if match data isn't there with an error. That isn't possible of
> course with further investigation but please make a note of this in the
> commit text to aid review.

We _do have_ Rockchip clock drivers serving multiple socs already
(rk3188+rk3066 for example) and as patterns are duplicated often from
one existing driver to a new one, I think it makes sense to have the
error handling done correctly.

So doing
	init_data = of_device_get_match_data(&pdev->dev);
	if (init_data)
		return -EINVAL;
as before.

If due to some strange coincidence the condition is triggered
this would cause a null-ptr-dereference with the direct call to
	init_data->scripts
below, which might or might not be hidden due to the (early-)console
being up yet, where with correct error handling a system might at
least come up to a point to complain about a missing clock driver.



> Also, please don't send new versions of
> patches in reply to previous versions of patches. It breaks my patch
> workflow. Thanks in advance.
> 
> >         if (init_data->inits)
> >                 init_data->inits(np);
> >
> 





_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-03-10 16:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-04  1:17 [PATCH] clk/rockchip: Use of_device_get_match_data() cgel.zte
2022-03-09 18:57 ` Stephen Boyd
2022-03-10 16:22   ` Heiko Stübner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-02-21  2:01 cgel.zte
2022-02-23 23:44 ` Heiko Stuebner

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=2697395.DCgNgQjydf@diego \
    --to=heiko@sntech.de \
    --cc=cgel.zte@gmail.com \
    --cc=chi.minghao@zte.com.cn \
    --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=sboyd@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).