Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: v4l: Avoid unaligned access warnings when printing 4cc modifiers

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>

authored by

Sakari Ailus and committed by
Mauro Carvalho Chehab
24bb30c8 c748f10c

+7 -5
+7 -5
drivers/media/v4l2-core/v4l2-ioctl.c
··· 279 279 const struct v4l2_vbi_format *vbi; 280 280 const struct v4l2_sliced_vbi_format *sliced; 281 281 const struct v4l2_window *win; 282 - const struct v4l2_sdr_format *sdr; 283 282 const struct v4l2_meta_format *meta; 283 + u32 pixelformat; 284 284 u32 planes; 285 285 unsigned i; 286 286 ··· 299 299 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 300 300 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: 301 301 mp = &p->fmt.pix_mp; 302 + pixelformat = mp->pixelformat; 302 303 pr_cont(", width=%u, height=%u, format=%p4cc, field=%s, colorspace=%d, num_planes=%u, flags=0x%x, ycbcr_enc=%u, quantization=%u, xfer_func=%u\n", 303 - mp->width, mp->height, &mp->pixelformat, 304 + mp->width, mp->height, &pixelformat, 304 305 prt_names(mp->field, v4l2_field_names), 305 306 mp->colorspace, mp->num_planes, mp->flags, 306 307 mp->ycbcr_enc, mp->quantization, mp->xfer_func); ··· 344 343 break; 345 344 case V4L2_BUF_TYPE_SDR_CAPTURE: 346 345 case V4L2_BUF_TYPE_SDR_OUTPUT: 347 - sdr = &p->fmt.sdr; 348 - pr_cont(", pixelformat=%p4cc\n", &sdr->pixelformat); 346 + pixelformat = p->fmt.sdr.pixelformat; 347 + pr_cont(", pixelformat=%p4cc\n", &pixelformat); 349 348 break; 350 349 case V4L2_BUF_TYPE_META_CAPTURE: 351 350 case V4L2_BUF_TYPE_META_OUTPUT: 352 351 meta = &p->fmt.meta; 352 + pixelformat = meta->dataformat; 353 353 pr_cont(", dataformat=%p4cc, buffersize=%u\n", 354 - &meta->dataformat, meta->buffersize); 354 + &pixelformat, meta->buffersize); 355 355 break; 356 356 } 357 357 }