media: v4l: Avoid unaligned access warnings when printing 4cc modifiers
authorSakari Ailus <sakari.ailus@linux.intel.com>
Mon, 10 Jan 2022 14:53:12 +0000 (15:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:14 +0000 (14:23 +0200)
commit26b1865f1fd4beaa84ca6e78c1b73def7d3fc01a
tree08834901746ae07167efc417c190b234a203c42a
parentef35afc268c5e0f892e1f717ff19678877287ac9
media: v4l: Avoid unaligned access warnings when printing 4cc modifiers

[ Upstream commit 24bb30c8c894ec7213ad810b46e2a6a4c12136c1 ]

Pointers V4L2 pixelformat and dataformat fields in a few packed structs
are directly passed to printk family of functions. 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.

Address the warning by copying the pixelformat or dataformat value to a
local variable first.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: e927e1e0f0dd ("v4l: ioctl: Use %p4cc printk modifier to print FourCC codes")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/v4l2-core/v4l2-ioctl.c