From: Michael Welling <mwelling@ieee.org>
To: Manfred Schlaegl <manfred.schlaegl@gmx.at>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Manfred Schlaegl <manfred.schlaegl@ginzinger.com>
Subject: Re: [PATCH] iio: mcp320x: Fix NULL pointer dereference
Date: Mon, 13 Jul 2015 09:16:07 -0500 [thread overview]
Message-ID: <20150713141607.GB3224@deathray> (raw)
In-Reply-To: <55A03142.1020106@gmx.at>
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 <manfred.schlaegl@gmx.at>
> ---
> 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 <mwelling@ieee.org>
> 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
>
next prev parent reply other threads:[~2015-07-13 14:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 20:55 [PATCH] iio: mcp320x: Fix NULL pointer dereference Manfred Schlaegl
2015-07-13 14:16 ` Michael Welling [this message]
2015-07-14 11:53 ` Manfred Schlaegl
2015-07-19 13:00 ` Jonathan Cameron
2015-07-19 23:56 ` Michael Welling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150713141607.GB3224@deathray \
--to=mwelling@ieee.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manfred.schlaegl@ginzinger.com \
--cc=manfred.schlaegl@gmx.at \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).