public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: William Breathitt Gray <vilhelm.gray@gmail.com>,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: stx104: Store channel output state values as int
Date: Sun, 24 Jul 2016 14:06:49 +0100	[thread overview]
Message-ID: <88bcc7a2-0f30-6f45-c8a8-37e2777c8dff@kernel.org> (raw)
In-Reply-To: <20160713144334.GA24521@sophia>

On 13/07/16 15:43, William Breathitt Gray wrote:
> The val parameter has a data type of int in the read_raw and write_raw
> callbacks. The chan_out_states array should have elements of type int in
> order to match the data type of the val parameter.
> 
> This patch fixes a possible integer overflow condition when the the int
> pointer val is dereferenced to store the unsigned int chan_out_states
> element in the read_raw callback.
> 
> Fixes: 97a445dad37a ("iio: Add IIO support for the DAC on the Apex Embedded Systems STX104")
> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
Isn't this only a problem if an out of range value was written
in the first place?  The values it'll take are only 16bits,
so a simple range check around that would fix the root problem.

J
> ---
>  drivers/iio/dac/stx104.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/dac/stx104.c b/drivers/iio/dac/stx104.c
> index 792a971..b22b744 100644
> --- a/drivers/iio/dac/stx104.c
> +++ b/drivers/iio/dac/stx104.c
> @@ -47,7 +47,7 @@ MODULE_PARM_DESC(base, "Apex Embedded Systems STX104 base addresses");
>   * @base:		base port address of the IIO device
>   */
>  struct stx104_iio {
> -	unsigned chan_out_states[STX104_NUM_CHAN];
> +	int chan_out_states[STX104_NUM_CHAN];
>  	unsigned base;
>  };
>  
> 

  reply	other threads:[~2016-07-24 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13 14:43 [PATCH] iio: stx104: Store channel output state values as int William Breathitt Gray
2016-07-24 13:06 ` Jonathan Cameron [this message]
2016-07-25 12:41   ` William Breathitt Gray

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=88bcc7a2-0f30-6f45-c8a8-37e2777c8dff@kernel.org \
    --to=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=pmeerw@pmeerw.net \
    --cc=vilhelm.gray@gmail.com \
    /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