diff mbox series

ASoC: codecs: Fix to avoid potential NULL pointer dereferences

Message ID 20190319005805.13823-1-pakki001@umn.edu (mailing list archive)
State New, archived
Headers show
Series ASoC: codecs: Fix to avoid potential NULL pointer dereferences | expand

Commit Message

Aditya Pakki March 19, 2019, 12:58 a.m. UTC
In sirf_audio_codec_driver_probe, of_match_node may fail and return a
NULL pointer. The patch avoids a potential NULL pointer dereference.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 sound/soc/codecs/sirf-audio-codec.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Aditya Pakki March 19, 2019, 1:03 a.m. UTC | #1
Apologies for the incorrect patch.
"match" is dead code and I will send a correct patch again.




On Mon, Mar 18, 2019 at 7:58 PM Aditya Pakki <pakki001@umn.edu> wrote:

> In sirf_audio_codec_driver_probe, of_match_node may fail and return a
> NULL pointer. The patch avoids a potential NULL pointer dereference.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  sound/soc/codecs/sirf-audio-codec.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/sound/soc/codecs/sirf-audio-codec.c
> b/sound/soc/codecs/sirf-audio-codec.c
> index e424499a8450..fd2bbd6a3c58 100644
> --- a/sound/soc/codecs/sirf-audio-codec.c
> +++ b/sound/soc/codecs/sirf-audio-codec.c
> @@ -464,6 +464,8 @@ static int sirf_audio_codec_driver_probe(struct
> platform_device *pdev)
>         const struct of_device_id *match;
>
>         match = of_match_node(sirf_audio_codec_of_match,
> pdev->dev.of_node);
> +       if (!match)
> +               return -ENXIO;
>
>         sirf_audio_codec = devm_kzalloc(&pdev->dev,
>                 sizeof(struct sirf_audio_codec), GFP_KERNEL);
> --
> 2.17.1
>
>
Steven Price March 22, 2019, 4:47 p.m. UTC | #2
On 19/03/2019 00:58, Aditya Pakki wrote:
> In sirf_audio_codec_driver_probe, of_match_node may fail and return a
> NULL pointer. The patch avoids a potential NULL pointer dereference.

Actually 'match' isn't used in this function...  So there's no chance of
a NULL dereference. You might as well remove the call.

Steve

> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  sound/soc/codecs/sirf-audio-codec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c
> index e424499a8450..fd2bbd6a3c58 100644
> --- a/sound/soc/codecs/sirf-audio-codec.c
> +++ b/sound/soc/codecs/sirf-audio-codec.c
> @@ -464,6 +464,8 @@ static int sirf_audio_codec_driver_probe(struct platform_device *pdev)
>  	const struct of_device_id *match;
>  
>  	match = of_match_node(sirf_audio_codec_of_match, pdev->dev.of_node);
> +	if (!match)
> +		return -ENXIO;
>  
>  	sirf_audio_codec = devm_kzalloc(&pdev->dev,
>  		sizeof(struct sirf_audio_codec), GFP_KERNEL);
>
diff mbox series

Patch

diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c
index e424499a8450..fd2bbd6a3c58 100644
--- a/sound/soc/codecs/sirf-audio-codec.c
+++ b/sound/soc/codecs/sirf-audio-codec.c
@@ -464,6 +464,8 @@  static int sirf_audio_codec_driver_probe(struct platform_device *pdev)
 	const struct of_device_id *match;
 
 	match = of_match_node(sirf_audio_codec_of_match, pdev->dev.of_node);
+	if (!match)
+		return -ENXIO;
 
 	sirf_audio_codec = devm_kzalloc(&pdev->dev,
 		sizeof(struct sirf_audio_codec), GFP_KERNEL);