lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 1 Aug 2020 15:52:39 +0100
From:   Jonathan Cameron <jic23@...nel.org>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     Daniel Campello <campello@...omium.org>,
        LKML <devicetree@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Douglas Anderson <dianders@...omium.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        Stephen Boyd <swboyd@...omium.org>,
        linux-iio <linux-iio@...r.kernel.org>
Subject: Re: [PATCH v3 06/15] iio: sx9310: Fixes various memory handling

On Fri, 31 Jul 2020 22:24:47 +0300
Andy Shevchenko <andy.shevchenko@...il.com> wrote:

> On Fri, Jul 31, 2020 at 7:49 PM Daniel Campello <campello@...omium.org> wrote:
> >
> > Makes use __aligned(8) to ensure that the timestamp is correctly aligned
> > when we call io_push_to_buffers_with_timestamp().
> > Also makes use of sizeof() for regmap_bulk_read instead of static value.  
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
> 
> > Signed-off-by: Daniel Campello <campello@...omium.org>
> > ---
> >
> > Changes in v3:
> >  - Changed buffer to struct type to align timestamp memory properly.
> >
> > Changes in v2:
> >  - Fixed commit message from "iio: sx9310: Align memory"
> >
> >  drivers/iio/proximity/sx9310.c | 13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c
> > index 2ed062d01634bc..c46584b4817b4a 100644
> > --- a/drivers/iio/proximity/sx9310.c
> > +++ b/drivers/iio/proximity/sx9310.c
> > @@ -132,8 +132,11 @@ struct sx9310_data {
> >          */
> >         bool prox_stat[SX9310_NUM_CHANNELS];
> >         bool trigger_enabled;
> > -       __be16 buffer[SX9310_NUM_CHANNELS +
> > -                     4]; /* 64-bit data + 64-bit timestamp */
> > +       /* Ensure correct alignment of timestamp when present. */
> > +       struct {
> > +               __be16 channels[SX9310_NUM_CHANNELS];
> > +               s64 ts __aligned(8);
> > +       } buffer;
> >         /* Remember enabled channels and sample rate during suspend. */
> >         unsigned int suspend_ctrl0;
> >         struct completion completion;
> > @@ -346,7 +349,7 @@ static int sx9310_read_prox_data(struct sx9310_data *data,
> >         if (ret < 0)
> >                 return ret;
> >
> > -       return regmap_bulk_read(data->regmap, chan->address, val, 2);
> > +       return regmap_bulk_read(data->regmap, chan->address, val, sizeof(*val));
> >  }
> >
> >  /*
> > @@ -697,10 +700,10 @@ static irqreturn_t sx9310_trigger_handler(int irq, void *private)
> >                 if (ret < 0)
> >                         goto out;
> >
> > -               data->buffer[i++] = val;
> > +               data->buffer.channels[i++] = val;
> >         }
> >
> > -       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
> > +       iio_push_to_buffers_with_timestamp(indio_dev, data->buffer.channels,

Whilst it's the same address, it makes more sense to push &data->buffer
Technically buffer.channels isn't large enough to meant the requirements
of iio_push_to_buffers_with_timestamp.

Otherwise, looks good.

Thanks,


Jonathan

> >                                            pf->timestamp);
> >
> >  out:
> > --
> > 2.28.0.163.g6104cc2f0b6-goog
> >  
> 
> 
> --
> With Best Regards,
> Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ