lkml.org 
[lkml]   [2015]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] ASoC: rsnd: fix a possible NULL dereference
Date

Hi LABBE

Thank you for your patch

> of_match_device could return NULL, and so cause a NULL pointer
> dereference later.
> Even if the probability of this case is very low, fixing it made
> static analyzers happy.
> Solving this with of_device_get_match_data made also code simplier.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
> sound/soc/sh/rcar/core.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
> index deed48e..54cc44c 100644
> --- a/sound/soc/sh/rcar/core.c
> +++ b/sound/soc/sh/rcar/core.c
> @@ -1204,7 +1204,6 @@ static int rsnd_probe(struct platform_device *pdev)
> struct rsnd_priv *priv;
> struct device *dev = &pdev->dev;
> struct rsnd_dai *rdai;
> - const struct of_device_id *of_id = of_match_device(rsnd_of_match, dev);
> const struct rsnd_of_data *of_data;
> int (*probe_func[])(struct platform_device *pdev,
> const struct rsnd_of_data *of_data,
> @@ -1221,11 +1220,13 @@ static int rsnd_probe(struct platform_device *pdev)
> };
> int ret, i;
>
> + of_data = of_device_get_match_data(dev);
> + if (!of_data)
> + return 1;

return 1 ?
You want to use -EINVAL ?



\
 
 \ /
  Last update: 2015-11-26 01:01    [W:0.097 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site