Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932894AbbGJUzt (ORCPT ); Fri, 10 Jul 2015 16:55:49 -0400 Received: from mout.gmx.net ([212.227.17.21]:56004 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751286AbbGJUzk (ORCPT ); Fri, 10 Jul 2015 16:55:40 -0400 Message-ID: <55A03142.1020106@gmx.at> Date: Fri, 10 Jul 2015 22:55:30 +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: Jonathan Cameron CC: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , Michael Welling , Manfred Schlaegl , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Manfred Schlaegl Subject: [PATCH] iio: mcp320x: Fix NULL pointer dereference Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:xMEnog0dz17GasGWVn3mVasTjUqN5xMAQqDPcbjMDM18jLdjVoK HmjyXKzYTWv5JKKnrtFCCY7nion5AXsxnuHHAxn+Q11iiAff42Soqc0BKWmOwFMXDlXXtAw buPlKqXPbxaXPv2hcgKY16Ha+aH7uSMYnU/VF2JjQfN9wHUVllL1YbJXGvqr5RF3rG+yMz3 sP063oNYL8ZC2EK9bgZnA== X-UI-Out-Filterresults: notjunk:1;V01:K0:yWojUOX0YkU=:H2RBsK1O+EuJwOMI1xF4YF Xv2TtXttjMidMh/ff5bZ1AlT6PcJ3I9qOubf/mTZyxdvfdHtaMC3vSaXLG2AT3DMi1LNEg41c vmWeSKEpwsFmXc3wn+dE7g4UFBtdVeD+WQetsV4E/gu2fRGXz1iEWhBMXlCuEaHtamyrjLeEx zAoaeDiYOhajGmsMqlDri27P+Kb+Md/1IRl4V+IWGmhHdeQTUEAvy51I1oOgL+aH7v/TtcvsP 6SBSuJzP2Hm3cUhmovcpAlMVOd+AYACUddGvynR6SLLB6BR32xcltxmqZIrvVabODGkTd+4k2 GGbT3DUYxJ1jQTgOn26byk5hy16ZhLuZhXz3Om9B6iqBNhNzORhRf77SaGMDDk3/GZWHEk+FA RUc6OnnuJUKqYiEtSubzI11ronJxZcKoHOqUNyZMiiOpwJI77EgvuJkDfQ9jpN2tBFb5+nLRW VZ7+sohA8ED7NplDnBrSoMTUfv3UR9SupwxOrc0iGe7EzWzvNhkYg47NwHdHPeb2R8UOnmON8 hmGwoRPMZkHD1K6EAm5QUk5EiL0BLb1w0Gg+R7bD0DKaCuS2cJiQLWZ71vI3Gi2WlF7IN9ExH c74I0qaJR9eahz4ZLhtSeN4gJpl+fS2uX2lE1UY1zmx+RGMPi7zrXWeequbcs1GifSBJnQ29W PvWaiQjnTPeR0d6cWrIpwTMJrP3FvUjfRwAsZOfVqHCRU1xMzu1GHdgCMYr37NOXOYts= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1390 Lines: 39 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; + 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 -- 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/