* [PATCH] ASoC: rsnd: fix a possible NULL dereference
@ 2015-11-25 12:49 LABBE Corentin
2015-11-25 23:46 ` Kuninori Morimoto
0 siblings, 1 reply; 4+ messages in thread
From: LABBE Corentin @ 2015-11-25 12:49 UTC (permalink / raw)
To: alsa-devel, broonie, kuninori.morimoto.gx, lgirdwood, perex,
tiwai
Cc: LABBE Corentin, linux-kernel
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;
info = devm_kzalloc(&pdev->dev, sizeof(struct rcar_snd_info),
GFP_KERNEL);
if (!info)
return -ENOMEM;
- of_data = of_id->data;
/*
* init priv data
--
2.4.10
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix a possible NULL dereference
2015-11-25 12:49 [PATCH] ASoC: rsnd: fix a possible NULL dereference LABBE Corentin
@ 2015-11-25 23:46 ` Kuninori Morimoto
2015-11-26 7:17 ` LABBE Corentin
0 siblings, 1 reply; 4+ messages in thread
From: Kuninori Morimoto @ 2015-11-25 23:46 UTC (permalink / raw)
To: LABBE Corentin; +Cc: alsa-devel, broonie, lgirdwood, perex, tiwai, linux-kernel
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 ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix a possible NULL dereference
2015-11-25 23:46 ` Kuninori Morimoto
@ 2015-11-26 7:17 ` LABBE Corentin
2015-11-30 16:38 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: LABBE Corentin @ 2015-11-26 7:17 UTC (permalink / raw)
To: Kuninori Morimoto
Cc: alsa-devel, broonie, lgirdwood, perex, tiwai, linux-kernel
On Wed, Nov 25, 2015 at 11:46:45PM +0000, Kuninori Morimoto wrote:
>
> 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 ?
>
I do that Uwe Kleine-König said to me to do in others thread:
https://lkml.org/lkml/2015/11/12/70 and https://lkml.org/lkml/2015/11/16/211
Regards
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: rsnd: fix a possible NULL dereference
2015-11-26 7:17 ` LABBE Corentin
@ 2015-11-30 16:38 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2015-11-30 16:38 UTC (permalink / raw)
To: LABBE Corentin
Cc: Kuninori Morimoto, alsa-devel, lgirdwood, perex, tiwai,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 585 bytes --]
On Thu, Nov 26, 2015 at 08:17:15AM +0100, LABBE Corentin wrote:
> On Wed, Nov 25, 2015 at 11:46:45PM +0000, Kuninori Morimoto wrote:
> > > + of_data = of_device_get_match_data(dev);
> > > + if (!of_data)
> > > + return 1;
> > return 1 ?
> > You want to use -EINVAL ?
> I do that Uwe Kleine-König said to me to do in others thread:
> https://lkml.org/lkml/2015/11/12/70 and https://lkml.org/lkml/2015/11/16/211
What error code to return is going to depend on the context - you need
to look at what the caller is expecting and how it will handle the value
returned.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-30 16:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-25 12:49 [PATCH] ASoC: rsnd: fix a possible NULL dereference LABBE Corentin
2015-11-25 23:46 ` Kuninori Morimoto
2015-11-26 7:17 ` LABBE Corentin
2015-11-30 16:38 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox