mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Peter Rosin <peda@axentia.se>, linux-kernel@vger.kernel.org
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Sanchayan Maity <maitysanchayan@gmail.com>,
	Gregor Boirie <gregor.boirie@parrot.com>,
	Alison Schofield <amsfield22@gmail.com>,
	Ken Lin <ken.lin@advantech.com>,
	linux-iio@vger.kernel.org
Subject: Re: [PATCH v2 2/2] iio: pressure: mpl115: do not rely on structure field ordering
Date: Sun, 5 Feb 2017 09:38:15 +0000	[thread overview]
Message-ID: <fe029d44-1e59-9854-aed3-e25d8833bc68@kernel.org> (raw)
In-Reply-To: <1485981657-14586-3-git-send-email-peda@axentia.se>

On 01/02/17 20:40, Peter Rosin wrote:
> Fixes a regression triggered by a change in the layout of
> struct iio_chan_spec, but the real bug is in the driver which assumed
> a specific structure layout in the first place. Hint: the three bits were
> not OR:ed together as implied by the indentation prior to this patch,
> there was a comma between the first two, which accidentally moved the
> ..._SCALE and ..._OFFSET bits to the next structure field. That field
> was .info_mask_shared_by_type before the _available attributes was added
> by commit 51239600074b ("iio:core: add a callback to allow drivers to
> provide _available attributes") and .info_mask_separate_available
> afterwards, and the regression happened.
> 
> info_mask_shared_by_type is actually a better choice than the originally
> intended info_mask_separate for the ..._SCALE and ..._OFFSET bits since
> a constant is returned from mpl115_read_raw for the scale/offset. Using
> info_mask_shared_by_type also preserves the behavior from before the
> regression and is therefore less likely to cause other interesting side
> effects.
> 
> The above mentioned regression causes unintended sysfs attibutes to
> show up that are not backed by code, in turn causing a NULL pointer
> defererence to happen on access.
> 
> Fixes: 3017d90e8931 ("iio: Add Freescale MPL115A2 pressure / temperature sensor driver")
> Fixes: 51239600074b ("iio:core: add a callback to allow drivers to provide _available attributes")
> Signed-off-by: Peter Rosin <peda@axentia.se>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/pressure/mpl115.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/pressure/mpl115.c b/drivers/iio/pressure/mpl115.c
> index 73f2f0c46e62..8f2bce213248 100644
> --- a/drivers/iio/pressure/mpl115.c
> +++ b/drivers/iio/pressure/mpl115.c
> @@ -137,6 +137,7 @@ static const struct iio_chan_spec mpl115_channels[] = {
>  	{
>  		.type = IIO_TEMP,
>  		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
> +		.info_mask_shared_by_type =
>  			BIT(IIO_CHAN_INFO_OFFSET) | BIT(IIO_CHAN_INFO_SCALE),
>  	},
>  };
> 

      reply	other threads:[~2017-02-05  9:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 20:40 [PATCH v2 0/2] iio: pressure: " Peter Rosin
2017-02-01 20:40 ` [PATCH v2 1/2] iio: pressure: mpl3115: " Peter Rosin
2017-02-05  9:37   ` Jonathan Cameron
2017-02-10 22:35     ` [PULL] IIO fixes for 4.10 set 3 - a couple of regression fixes Peter Rosin
2017-02-11  7:17       ` Greg Kroah-Hartman
2017-02-11  9:16         ` Jonathan Cameron
2017-02-14 14:29           ` Peter Rosin
2017-02-01 20:40 ` [PATCH v2 2/2] iio: pressure: mpl115: do not rely on structure field ordering Peter Rosin
2017-02-05  9:38   ` Jonathan Cameron [this message]

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=fe029d44-1e59-9854-aed3-e25d8833bc68@kernel.org \
    --to=jic23@kernel.org \
    --cc=amsfield22@gmail.com \
    --cc=gregor.boirie@parrot.com \
    --cc=ken.lin@advantech.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maitysanchayan@gmail.com \
    --cc=peda@axentia.se \
    --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

Powered by JetHome