lkml.org 
[lkml]   [2022]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] clk/samsung: Use of_device_get_match_data()
From
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

\
 
 \ /
  Last update: 2022-03-04 08:11    [W:0.073 / U:1.276 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site