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]
Message-ID: <20210910075154.GF26100@pengutronix.de>
Date:   Fri, 10 Sep 2021 09:51:54 +0200
From:   Oleksij Rempel <o.rempel@...gutronix.de>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     Alexandru Ardelean <alexandru.ardelean@...log.com>,
        Mark Brown <broonie@...nel.org>,
        kernel test robot <lkp@...el.com>, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
        linux-spi@...r.kernel.org, David Jander <david@...tonic.nl>
Subject: Re: [PATCH v1] Input: ads7846: ads7846_get_value - fix unaligned
 pointer value warning

Hi Dmitry,

On Thu, Sep 09, 2021 at 10:04:16PM -0700, Dmitry Torokhov wrote:
> Hi Oleksij,
> 
> On Wed, Jul 07, 2021 at 02:41:15PM +0200, Oleksij Rempel wrote:
> > Fix warning reported by the kernel test robot:
> > drivers/input/touchscreen/ads7846.c:705:24: warning: taking address
> > of packed member 'data' of class or structure 'ads7846_buf' may result
> > in an unaligned pointer value [-Waddress-of-packed-member]
> > 
> > Fixes: 6965eece2a89 ("Input: ads7846 - convert to one message")
> > Reported-by: kernel test robot <lkp@...el.com>
> > Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> > ---
> >  drivers/input/touchscreen/ads7846.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> > index adb4c2230c31..1987dedac94f 100644
> > --- a/drivers/input/touchscreen/ads7846.c
> > +++ b/drivers/input/touchscreen/ads7846.c
> > @@ -702,7 +702,7 @@ static int ads7846_get_value(struct ads7846_buf *buf)
> >  {
> >  	int value;
> >  
> > -	value = be16_to_cpup(&buf->data);
> > +	value = get_unaligned_be16(&buf->data);
> 
> ds7846_buf is declared as packed so I believe using be16_to_cpu(buf->data)
> will suffice.

The pointer to the data is is off by 8 bits, so it is not naturally
aligned. This is why we need to use function which is dealing with
unaligned pointers. 

Regards,
Oleksij
-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ