CC: llvm(a)lists.linux.dev CC: kbuild-all(a)lists.01.org In-Reply-To: <20211128232115.38833-1-djrscally@gmail.com> References: <20211128232115.38833-1-djrscally@gmail.com> TO: Daniel Scally TO: linux-media(a)vger.kernel.org CC: sakari.ailus(a)linux.intel.com CC: hdegoede(a)redhat.com CC: laurent.pinchart(a)ideasonboard.com CC: kieran.bingham(a)ideasonboard.com Hi Daniel, I love your patch! Perhaps something to improve: [auto build test WARNING on media-tree/master] [also build test WARNING on linus/master v5.16-rc3 next-20211203] [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/0day-ci/linux/commits/Daniel-Scally/media-i2c-Add-driver-for-DW9719-VCM/20211129-072436 base: git://linuxtv.org/media_tree.git master :::::: branch date: 6 days ago :::::: commit date: 6 days ago config: i386-randconfig-c001-20211130 (https://download.01.org/0day-ci/archive/20211205/202112050308.lEaCEX4U-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 25eb7fa01d7ebbe67648ea03841cda55b4239ab2) 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/0day-ci/linux/commit/8bbbe049053a268d99463f6fda429d0af571a27a git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Daniel-Scally/media-i2c-Add-driver-for-DW9719-VCM/20211129-072436 git checkout 8bbbe049053a268d99463f6fda429d0af571a27a # save the config file to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot clang-analyzer warnings: (new ones prefixed by >>) ^~~~~ sound/drivers/vx/vx_pcm.c:217:2: note: Taking false branch if (! err) ^ sound/drivers/vx/vx_pcm.c:219:2: note: Returning without writing to '*state' return err; ^ sound/drivers/vx/vx_pcm.c:323:6: note: Returning from 'vx_get_pipe_state' if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_pcm.c:323:6: note: Assuming the condition is false if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_pcm.c:323:2: note: Taking false branch if (vx_get_pipe_state(chip, pipe, &cur_state) < 0) ^ sound/drivers/vx/vx_pcm.c:325:12: note: The right operand of '==' is a garbage value if (state == cur_state) ^ ~~~~~~~~~ sound/drivers/vx/vx_pcm.c:1225:3: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy] strcpy(pcm->name, chip->card->shortname); ^~~~~~ sound/drivers/vx/vx_pcm.c:1225:3: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 strcpy(pcm->name, chip->card->shortname); ^~~~~~ Suppressed 4 warnings (4 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 8 warnings generated. sound/drivers/vx/vx_mixer.c:836:55: warning: The left operand of '>>' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult] ucontrol->value.integer.value[0] = meter[0].vu_level >> METER_SHIFT; ~~~~~~~~~~~~~~~~~ ^ sound/drivers/vx/vx_mixer.c:835:2: note: Calling 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, capture, meter); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:6: note: Assuming the condition is true if (chip->chip_status & VX_STAT_IS_STALE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:2: note: Taking true branch if (chip->chip_status & VX_STAT_IS_STALE) ^ sound/drivers/vx/vx_mixer.c:368:3: note: Returning without writing to 'info->vu_level' return -EBUSY; ^ sound/drivers/vx/vx_mixer.c:835:2: note: Returning from 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, capture, meter); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:836:55: note: The left operand of '>>' is a garbage value ucontrol->value.integer.value[0] = meter[0].vu_level >> METER_SHIFT; ~~~~~~~~~~~~~~~~~ ^ sound/drivers/vx/vx_mixer.c:849:57: warning: The left operand of '>>' is a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult] ucontrol->value.integer.value[0] = meter[0].peak_level >> METER_SHIFT; ~~~~~~~~~~~~~~~~~~~ ^ sound/drivers/vx/vx_mixer.c:848:2: note: Calling 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, capture, meter); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:6: note: Assuming the condition is true if (chip->chip_status & VX_STAT_IS_STALE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:2: note: Taking true branch if (chip->chip_status & VX_STAT_IS_STALE) ^ sound/drivers/vx/vx_mixer.c:368:3: note: Returning without writing to 'info->peak_level' return -EBUSY; ^ sound/drivers/vx/vx_mixer.c:848:2: note: Returning from 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, capture, meter); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:849:57: note: The left operand of '>>' is a garbage value ucontrol->value.integer.value[0] = meter[0].peak_level >> METER_SHIFT; ~~~~~~~~~~~~~~~~~~~ ^ sound/drivers/vx/vx_mixer.c:863:35: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] ucontrol->value.integer.value[0] = meter[0].saturated; ^ ~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:862:2: note: Calling 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, 1, meter); /* capture only */ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:6: note: Assuming the condition is true if (chip->chip_status & VX_STAT_IS_STALE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:367:2: note: Taking true branch if (chip->chip_status & VX_STAT_IS_STALE) ^ sound/drivers/vx/vx_mixer.c:368:3: note: Returning without writing to 'info->saturated' return -EBUSY; ^ sound/drivers/vx/vx_mixer.c:862:2: note: Returning from 'vx_get_audio_vu_meter' vx_get_audio_vu_meter(chip, audio, 1, meter); /* capture only */ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:863:35: note: Assigned value is garbage or undefined ucontrol->value.integer.value[0] = meter[0].saturated; ^ ~~~~~~~~~~~~~~~~~~ sound/drivers/vx/vx_mixer.c:906:2: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy] strcpy(card->mixername, card->driver); ^~~~~~ sound/drivers/vx/vx_mixer.c:906:2: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 strcpy(card->mixername, card->driver); ^~~~~~ Suppressed 4 warnings (4 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 9 warnings generated. >> drivers/media/i2c/dw9719.c:126:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] ret = -ENXIO; ^ ~~~~~~ drivers/media/i2c/dw9719.c:126:3: note: Value stored to 'ret' is never read ret = -ENXIO; ^ ~~~~~~ drivers/media/i2c/dw9719.c:146:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] ret = dw9719_i2c_wr8(dw9719->client, DW9719_CONTROL, 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/dw9719.c:146:2: note: Value stored to 'ret' is never read ret = dw9719_i2c_wr8(dw9719->client, DW9719_CONTROL, 1); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 9 warnings generated. drivers/media/i2c/adv7175.c:416:3: warning: Value stored to 'i' is never read [clang-analyzer-deadcode.DeadStores] i = adv7175_write(sd, 0x07, TR0MODE | TR0RST); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/adv7175.c:416:3: note: Value stored to 'i' is never read i = adv7175_write(sd, 0x07, TR0MODE | TR0RST); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/adv7175.c:417:3: warning: Value stored to 'i' is never read [clang-analyzer-deadcode.DeadStores] i = adv7175_write(sd, 0x07, TR0MODE); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/adv7175.c:417:3: note: Value stored to 'i' is never read i = adv7175_write(sd, 0x07, TR0MODE); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. Suppressed 7 warnings (7 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. Suppressed 18 warnings (8 in non-user code, 10 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 11 warnings generated. drivers/media/i2c/adv7842.c:3499:60: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult] rev = adv_smbus_read_byte_data_check(client, 0xea, false) << 8 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ drivers/media/i2c/adv7842.c:3469:7: note: Calling 'i2c_check_functionality' if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/i2c.h:913:9: note: Assuming the condition is true return (func & i2c_get_functionality(adap)) == func; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/i2c.h:913:2: note: Returning the value 1, which participates in a condition later return (func & i2c_get_functionality(adap)) == func; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/adv7842.c:3469:7: note: Returning from 'i2c_check_functionality' if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/adv7842.c:3469:2: note: Taking false branch if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) ^ drivers/media/i2c/adv7842.c:3472:13: note: Assuming 'debug' is < 1 v4l_dbg(1, debug, client, "detecting adv7842 client on address 0x%x\n", ^ include/media/v4l2-common.h:43:7: note: expanded from macro 'v4l_dbg' if (debug >= (level)) \ ^~~~~~~~~~~~~~~~ drivers/media/i2c/adv7842.c:3472:2: note: Taking false branch v4l_dbg(1, debug, client, "detecting adv7842 client on address 0x%x\n", ^ include/media/v4l2-common.h:43:3: note: expanded from macro 'v4l_dbg' if (debug >= (level)) \ ^ drivers/media/i2c/adv7842.c:3472:2: note: Loop condition is false. Exiting loop v4l_dbg(1, debug, client, "detecting adv7842 client on address 0x%x\n", ^ include/media/v4l2-common.h:42:2: note: expanded from macro 'v4l_dbg' do { \ ^ drivers/media/i2c/adv7842.c:3475:6: note: Assuming 'pdata' is non-null if (!pdata) { ^~~~~~ drivers/media/i2c/adv7842.c:3475:2: note: Taking false branch if (!pdata) { ^ drivers/media/i2c/adv7842.c:3481:6: note: Assuming 'state' is non-null if (!state) ^~~~~~ drivers/media/i2c/adv7842.c:3481:2: note: Taking false branch if (!state) ^ drivers/media/i2c/adv7842.c:3495:23: note: Assuming field 'input' is not equal to ADV7842_SELECT_HDMI_PORT_A state->hdmi_port_a = pdata->input == ADV7842_SELECT_HDMI_PORT_A; vim +/ret +126 drivers/media/i2c/dw9719.c 8bbbe049053a26 Daniel Scally 2021-11-28 114 8bbbe049053a26 Daniel Scally 2021-11-28 115 static int dw9719_detect(struct dw9719_device *dw9719) 8bbbe049053a26 Daniel Scally 2021-11-28 116 { 8bbbe049053a26 Daniel Scally 2021-11-28 117 int ret; 8bbbe049053a26 Daniel Scally 2021-11-28 118 u8 val; 8bbbe049053a26 Daniel Scally 2021-11-28 119 8bbbe049053a26 Daniel Scally 2021-11-28 120 ret = dw9719_i2c_rd8(dw9719->client, DW9719_INFO, &val); 8bbbe049053a26 Daniel Scally 2021-11-28 121 if (ret < 0) 8bbbe049053a26 Daniel Scally 2021-11-28 122 return ret; 8bbbe049053a26 Daniel Scally 2021-11-28 123 8bbbe049053a26 Daniel Scally 2021-11-28 124 if (val != DW9719_ID) { 8bbbe049053a26 Daniel Scally 2021-11-28 125 dev_err(dw9719->dev, "Failed to detect correct id\n"); 8bbbe049053a26 Daniel Scally 2021-11-28 @126 ret = -ENXIO; 8bbbe049053a26 Daniel Scally 2021-11-28 127 } 8bbbe049053a26 Daniel Scally 2021-11-28 128 8bbbe049053a26 Daniel Scally 2021-11-28 129 return 0; 8bbbe049053a26 Daniel Scally 2021-11-28 130 } 8bbbe049053a26 Daniel Scally 2021-11-28 131 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org