Re: [PATCH v7 2/8] media: uvcvideo: Add support for per-device control mapping overrides

From: kernel test robot
Date: Fri Jun 17 2022 - 10:40:52 EST


Hi Ricardo,

I love your patch! Perhaps something to improve:

[auto build test WARNING on media-tree/master]
[also build test WARNING on linus/master v5.19-rc2 next-20220617]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Ricardo-Ribalda/uvcvideo-Fix-handling-of-power_line_frequency/20220617-185644
base: git://linuxtv.org/media_tree.git master
config: hexagon-randconfig-r045-20220617 (https://download.01.org/0day-ci/archive/20220617/202206172239.M4dQBUhz-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d764aa7fc6b9cc3fbe960019018f5f9e941eb0a6)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/10bdca4191d7a8be97c77dbe4ba89c05713ee0e2
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Ricardo-Ribalda/uvcvideo-Fix-handling-of-power_line_frequency/20220617-185644
git checkout 10bdca4191d7a8be97c77dbe4ba89c05713ee0e2
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/media/usb/uvc/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/media/usb/uvc/uvc_ctrl.c:2442:6: warning: variable 'mapping' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (chain->dev->info->mappings) {
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/uvc/uvc_ctrl.c:2459:9: note: uninitialized use occurs here
mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings);
^~~~~~~
drivers/media/usb/uvc/uvc_ctrl.c:2442:2: note: remove the 'if' if its condition is always true
if (chain->dev->info->mappings) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/uvc/uvc_ctrl.c:2406:43: note: initialize the variable 'mapping' to silence this warning
const struct uvc_control_mapping *mapping;
^
= NULL
1 warning generated.


vim +2442 drivers/media/usb/uvc/uvc_ctrl.c

2396
2397 /*
2398 * Add control information and hardcoded stock control mappings to the given
2399 * device.
2400 */
2401 static void uvc_ctrl_init_ctrl(struct uvc_video_chain *chain,
2402 struct uvc_control *ctrl)
2403 {
2404 const struct uvc_control_info *info = uvc_ctrls;
2405 const struct uvc_control_info *iend = info + ARRAY_SIZE(uvc_ctrls);
2406 const struct uvc_control_mapping *mapping;
2407 const struct uvc_control_mapping *mend;
2408
2409 /* XU controls initialization requires querying the device for control
2410 * information. As some buggy UVC devices will crash when queried
2411 * repeatedly in a tight loop, delay XU controls initialization until
2412 * first use.
2413 */
2414 if (UVC_ENTITY_TYPE(ctrl->entity) == UVC_VC_EXTENSION_UNIT)
2415 return;
2416
2417 for (; info < iend; ++info) {
2418 if (uvc_entity_match_guid(ctrl->entity, info->entity) &&
2419 ctrl->index == info->index) {
2420 uvc_ctrl_add_info(chain->dev, ctrl, info);
2421 /*
2422 * Retrieve control flags from the device. Ignore errors
2423 * and work with default flag values from the uvc_ctrl
2424 * array when the device doesn't properly implement
2425 * GET_INFO on standard controls.
2426 */
2427 uvc_ctrl_get_flags(chain->dev, ctrl, &ctrl->info);
2428 break;
2429 }
2430 }
2431
2432 if (!ctrl->initialized)
2433 return;
2434
2435 /*
2436 * First check if the device provides a custom mapping for this control,
2437 * used to override standard mappings for non-conformant devices. Don't
2438 * process standard mappings if a custom mapping is found. This
2439 * mechanism doesn't support combining standard and custom mappings for
2440 * a single control.
2441 */
> 2442 if (chain->dev->info->mappings) {
2443 bool custom = false;
2444 unsigned int i;
2445
2446 for (i = 0; (mapping = chain->dev->info->mappings[i]); ++i) {
2447 if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
2448 ctrl->info.selector == mapping->selector) {
2449 __uvc_ctrl_add_mapping(chain, ctrl, mapping);
2450 custom = true;
2451 }
2452 }
2453
2454 if (custom)
2455 return;
2456 }
2457
2458 /* Process common mappings next. */
2459 mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings);
2460 for (mapping = uvc_ctrl_mappings; mapping < mend; ++mapping) {
2461 if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
2462 ctrl->info.selector == mapping->selector)
2463 __uvc_ctrl_add_mapping(chain, ctrl, mapping);
2464 }
2465
2466 /* Finally process version-specific mappings. */
2467 if (chain->dev->uvc_version < 0x0150) {
2468 mapping = uvc_ctrl_mappings_uvc11;
2469 mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc11);
2470 } else {
2471 mapping = uvc_ctrl_mappings_uvc15;
2472 mend = mapping + ARRAY_SIZE(uvc_ctrl_mappings_uvc15);
2473 }
2474
2475 for (; mapping < mend; ++mapping) {
2476 if (uvc_entity_match_guid(ctrl->entity, mapping->entity) &&
2477 ctrl->info.selector == mapping->selector)
2478 __uvc_ctrl_add_mapping(chain, ctrl, mapping);
2479 }
2480 }
2481

--
0-DAY CI Kernel Test Service
https://01.org/lkp