Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbbKZHRY (ORCPT ); Thu, 26 Nov 2015 02:17:24 -0500 Received: from mail-wm0-f42.google.com ([74.125.82.42]:35818 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbbKZHRT (ORCPT ); Thu, 26 Nov 2015 02:17:19 -0500 Date: Thu, 26 Nov 2015 08:17:15 +0100 From: LABBE Corentin To: Kuninori Morimoto Cc: alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ASoC: rsnd: fix a possible NULL dereference Message-ID: <20151126071715.GB28184@Red> References: <1448455796-27315-1-git-send-email-clabbe.montjoie@gmail.com> <8737vtejg6.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8737vtejg6.wl%kuninori.morimoto.gx@renesas.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1758 Lines: 51 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 > > --- > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/