Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752513AbdGISIu (ORCPT ); Sun, 9 Jul 2017 14:08:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:52520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752225AbdGISIs (ORCPT ); Sun, 9 Jul 2017 14:08:48 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF88822BE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sun, 9 Jul 2017 19:08:43 +0100 From: Jonathan Cameron To: Martin Blumenstingl Cc: "Gustavo A. R. Silva" , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Carlo Caione , Kevin Hilman , linux-iio@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] iio: adc: meson-saradc: add NULL check on of_match_device() return value Message-ID: <20170709190843.0bfa292f@kernel.org> In-Reply-To: References: <20170707064630.GA21945@embeddedgus> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1851 Lines: 53 On Sat, 8 Jul 2017 15:42:46 +0200 Martin Blumenstingl wrote: > On Fri, Jul 7, 2017 at 8:46 AM, Gustavo A. R. Silva > wrote: > > Check return value from call to of_match_device() > > in order to prevent a NULL pointer dereference. > > > > In case of NULL print error message and return -ENODEV > > > > Signed-off-by: Gustavo A. R. Silva > thanks for finding this. a crash here is a rather theoretical problem > (since all compatible strings have their corresponding match data) - > but it doesn't hurt either, so: > > Acked-by: Martin Blumenstingl Applied. Jonathan > > > > --- > > drivers/iio/adc/meson_saradc.c | 5 +++++ > > 1 file changed, 5 insertions(+) > > > > diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c > > index 83da50e..07dbcc3 100644 > > --- a/drivers/iio/adc/meson_saradc.c > > +++ b/drivers/iio/adc/meson_saradc.c > > @@ -915,6 +915,11 @@ static int meson_sar_adc_probe(struct platform_device *pdev) > > init_completion(&priv->done); > > > > match = of_match_device(meson_sar_adc_of_match, &pdev->dev); > > + if (!match) { > > + dev_err(&pdev->dev, "failed to match device\n"); > > + return -ENODEV; > > + } > > + > > priv->data = match->data; > > > > indio_dev->name = priv->data->name; > > -- > > 2.5.0 > > > > > > _______________________________________________ > > linux-amlogic mailing list > > linux-amlogic@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-amlogic > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html