Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752471AbbGNLxx (ORCPT ); Tue, 14 Jul 2015 07:53:53 -0400 Received: from mout.gmx.net ([212.227.17.20]:55143 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751882AbbGNLxw (ORCPT ); Tue, 14 Jul 2015 07:53:52 -0400 Message-ID: <55A4F848.8060507@gmx.at> Date: Tue, 14 Jul 2015 13:53:44 +0200 From: Manfred Schlaegl User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Michael Welling CC: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Manfred Schlaegl Subject: Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference References: <55A03142.1020106@gmx.at> <20150713141607.GB3224@deathray> In-Reply-To: <20150713141607.GB3224@deathray> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:W/4Ap72en5lavSiaf76l/IMYS+2xoRzH5FB2wHrazeJ76JaGSxy /FLI7sqTlreKWZmDpIcdUGGn9iLt/hvc+JtcyRAmDjzwV16BoFhqCQw9Et9Hsk5JnyjIGYb gSFM2f9du8ex8+jgQuBjzdXW6dQ8i2iA66NILJNtNJDVoepN4Cs2IcBTL7sVFRMgizA2Jcf EMivx7kySOVIhfJP3FH5g== X-UI-Out-Filterresults: notjunk:1;V01:K0:aBmsB1Exylw=:GZ9UKHPpz9Dtt10I2pRxj9 nA3/74xZ8H/7dhzpLmGkqGUet/gXNbHn0teYhIBPo1ORZlz79qM8Da/+AoluI7fEQXLZiwSDO ht2Wb0IY1tbVMskagL/9iWI06Alg8k0yovjjzDRfpeDDnVZhOrC2fawGtNzNHwTr6t8IleocG VyIVuW4YPqMfv5ac8MdKax3WNAlObM9XigVblfx1uUco2I2Y/Pr/lQUGQ0RKFX74+XcBfJi4I /1B/DOV+rhHPr7ei2a+elBOplFXsXPjX7n5mwuorH05yqunS5vnvmiwnrleUVNziPNc3wlxwS ptC/aWm8anrnpn2b9uTjA9hJNI1W94cvPjdkssfFiyuMaMxW/nnLA/BU3AnURHWl1FCEHjl9i KbVsF4urd10P+XBWdXAG9Ro9U9DBDSM3PW+pj1no0V8F5GFxUd0rj0dcvLczAfp/Gcd6ZIuhE 7WjzKVst9PnYFr0s9hvddPfYxCRK2rUmgCw9MN+KCw2TPgpN+fFlpGJipUFN/A3cJD1M4c4Nh 5tiVX2oVrFIUFRJOZap6IbVBU9SFi1HFjSz+B4xksTR6JvaMdTBKykfnRyjIPimuNAs0mmWuv WxeFm4CbcTYCvJMI0/HlaoyDYNFw+j2sQzDBTtNDfnKEzvJ2IKGwGJqwJlDVHaBHJCr5fSX7V gcI/6w02Hm8Hux3rdHuV4DEiX8DBSiLoNeKg0Vp8tXKIcAxrd8k72Y+KpQD3hbxjDPR4= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1724 Lines: 51 On 2015-07-13 16:16, Michael Welling wrote: > On Fri, Jul 10, 2015 at 10:55:30PM +0200, Manfred Schlaegl wrote: >> On reading in_voltage_scale of we got an NULL pointer dereference Oops. >> >> The reason for this is, that mcp320x_read_raw tries to access >> chip_info->resolution from struct mcp320x, but chip_info is never set. >> >> chip_info was never set since the driver was added, but there was no >> acute problem, because it was not referenced. >> The acute problem exists since >> b12206e917ac34bec41b9ff93d37d8bd53a2b3bc >> iio: adc: mcp320x. Add support for more ADCs >> >> This patch fixes the issue by setting chip_info in mcp320x_probe. >> >> Signed-off-by: Manfred Schlaegl >> --- >> drivers/iio/adc/mcp320x.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c >> index 8d9c9b9..d819823 100644 >> --- a/drivers/iio/adc/mcp320x.c >> +++ b/drivers/iio/adc/mcp320x.c >> @@ -299,6 +299,8 @@ static int mcp320x_probe(struct spi_device *spi) >> indio_dev->channels = chip_info->channels; >> indio_dev->num_channels = chip_info->num_channels; >> >> + adc->chip_info = chip_info; >> + > > Looks good to me. > > Reviewed-by: Michael Welling > >> adc->transfer[0].tx_buf = &adc->tx_buf; >> adc->transfer[0].len = sizeof(adc->tx_buf); >> adc->transfer[1].rx_buf = adc->rx_buf; >> -- >> 1.7.10.4 >> Thanks for reviewing! best regards, manfred -- 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/