All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, hverkuil@xs4all.nl
Subject: Re: [PATCH 1/1] v4l: Avoid unaligned access warnings when printing 4cc modifiers
Date: Tue, 11 Jan 2022 12:07:57 +0200	[thread overview]
Message-ID: <Yd1W/cQ1G4/HpFMi@smile.fi.intel.com> (raw)
In-Reply-To: <CAKwvOdnfX1DzgkzCPY7N4LiJDJTGxsKNQbRMmmkt7o5z5O-W9w@mail.gmail.com>

On Mon, Jan 10, 2022 at 03:11:18PM -0800, Nick Desaulniers wrote:
> On Mon, Jan 10, 2022 at 2:48 PM Sakari Ailus
> <sakari.ailus@linux.intel.com> wrote:
> >
> > Pointers V4L2 pixelformat and dataformat fields in a few packed structs
> > are directly passed to printk family of functions.
> 
> I would rephrase the below statement...
> 
> > This could result in an
> > unaligned access albeit no such possibility appears to exist at the
> > moment i.e. this clang warning appears to be a false positive.
> 
> ...to:
> 
> warning: taking address of packed member 'pixelformat' of class or
> structure 'v4l2_pix_format_mplane' may result in an unaligned pointer
> value [-Waddress-of-packed-member]
> 
> The warning is correct;

Exactly. I'm going to repeat that in the comment to my patch.

> because `struct v4l2_pix_format_mplane` is
> __packed, it's members also have __aligned(1).  Taking the address of
> such members results in the use of underaligned pointers which is UB
> and may be caught by UBSAN or fault on architectures without unaligned
> loads should the struct instance happen to be allocated without any
> natural alignment.

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2022-01-11 10:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 22:46 [PATCH 1/1] v4l: Avoid unaligned access warnings when printing 4cc modifiers Sakari Ailus
2022-01-10 23:11 ` Nick Desaulniers
2022-01-10 23:12   ` Fwd: " Nick Desaulniers
2022-01-11 10:07   ` Andy Shevchenko [this message]
2022-01-11 10:47   ` Sakari Ailus
2022-01-11 12:27     ` Andy Shevchenko
2022-01-11 20:48       ` Nick Desaulniers
2022-01-11 21:07         ` Sakari Ailus
2022-01-11 21:36           ` Nick Desaulniers
2022-01-11 21:57             ` Sakari Ailus
2022-01-11 11:37 ` Andy Shevchenko

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=Yd1W/cQ1G4/HpFMi@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.