mbox series

[0/2] IIO: Alignment fixes part 1 - sizes too small as well.

Message ID 20210501165314.511954-1-jic23@kernel.org (mailing list archive)
Headers show
Series IIO: Alignment fixes part 1 - sizes too small as well. | expand

Message

Jonathan Cameron May 1, 2021, 4:53 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

I finally got around to do a manual audit of all the calls to
iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
of:
1. 8 byte alignment of the provided buffer.
2. space for an 8 byte naturally aligned timestamp to be inserted at the
   end.

As discussed previous in
https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
it is not easy to fix the alignment issue without requiring a bounce buffer
(see part 4 of the alignment fixes for a proposal for that where it is
absolutely necessary).

In these cases the buffer is neither big enough, nor correctly aligned
so fix both issues in one go.

Cc: Daniel Junho <djunho@gmail.com>

Jonathan Cameron (2):
  iio: adc: ad7768-1: Fix too small buffer passed to
    iio_push_to_buffers_with_timestamp()
  iio: adc: ad7923: Fix undersized rx buffer.

 drivers/iio/adc/ad7768-1.c | 8 ++++++--
 drivers/iio/adc/ad7923.c   | 4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Andy Shevchenko May 1, 2021, 7:14 p.m. UTC | #1
On Sat, May 1, 2021 at 7:55 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> I finally got around to do a manual audit of all the calls to
> iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
> of:
> 1. 8 byte alignment of the provided buffer.
> 2. space for an 8 byte naturally aligned timestamp to be inserted at the
>    end.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> As discussed previous in
> https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
> it is not easy to fix the alignment issue without requiring a bounce buffer
> (see part 4 of the alignment fixes for a proposal for that where it is
> absolutely necessary).
>
> In these cases the buffer is neither big enough, nor correctly aligned
> so fix both issues in one go.
>
> Cc: Daniel Junho <djunho@gmail.com>
>
> Jonathan Cameron (2):
>   iio: adc: ad7768-1: Fix too small buffer passed to
>     iio_push_to_buffers_with_timestamp()
>   iio: adc: ad7923: Fix undersized rx buffer.
>
>  drivers/iio/adc/ad7768-1.c | 8 ++++++--
>  drivers/iio/adc/ad7923.c   | 4 +++-
>  2 files changed, 9 insertions(+), 3 deletions(-)
>
> --
> 2.31.1
>
Jonathan Cameron May 13, 2021, 5:14 p.m. UTC | #2
On Sat, 1 May 2021 22:14:16 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sat, May 1, 2021 at 7:55 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > I finally got around to do a manual audit of all the calls to
> > iio_push_to_buffers_with_timestamp() which has the somewhat odd requirements
> > of:
> > 1. 8 byte alignment of the provided buffer.
> > 2. space for an 8 byte naturally aligned timestamp to be inserted at the
> >    end.  
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks!

Applied to the fixes-togreg branch of iio.git and marked for stable.

For these two I decided to go the quick way as they are broken even on systems
where the alignment issue doesn't matter.

Thanks,

Jonathan

> 
> > As discussed previous in
> > https://lore.kernel.org/linux-iio/20200920112742.170751-1-jic23@kernel.org/
> > it is not easy to fix the alignment issue without requiring a bounce buffer
> > (see part 4 of the alignment fixes for a proposal for that where it is
> > absolutely necessary).
> >
> > In these cases the buffer is neither big enough, nor correctly aligned
> > so fix both issues in one go.
> >
> > Cc: Daniel Junho <djunho@gmail.com>
> >
> > Jonathan Cameron (2):
> >   iio: adc: ad7768-1: Fix too small buffer passed to
> >     iio_push_to_buffers_with_timestamp()
> >   iio: adc: ad7923: Fix undersized rx buffer.
> >
> >  drivers/iio/adc/ad7768-1.c | 8 ++++++--
> >  drivers/iio/adc/ad7923.c   | 4 +++-
> >  2 files changed, 9 insertions(+), 3 deletions(-)
> >
> > --
> > 2.31.1
> >  
> 
>