:::::: :::::: Manual check reason: "low confidence static check first_new_problem: drivers/pwm/pwm-fsl-ftm.c:128:2: warning: Division by zero [clang-analyzer-core.DivideZero]" :::::: BCC: lkp@intel.com CC: llvm@lists.linux.dev CC: oe-kbuild-all@lists.linux.dev CC: linux-kernel@vger.kernel.org TO: Hans de Goede tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 97ee9d1c16963375eefdf964c429897d27e28956 commit: 3cd8cc98d63492f6f69edd4486c9bd1fe29f91c3 platform/x86: Drop the PMC_ATOM Kconfig option date: 6 months ago :::::: branch date: 18 hours ago :::::: commit date: 6 months ago config: i386-randconfig-c001-20221128 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) 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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3cd8cc98d63492f6f69edd4486c9bd1fe29f91c3 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout 3cd8cc98d63492f6f69edd4486c9bd1fe29f91c3 # save the config file COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386 clang-analyzer If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot clang_analyzer warnings: (new ones prefixed by >>) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:527:4: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(&desc, 0, sizeof(desc)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:527:4: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(&desc, 0, sizeof(desc)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:674:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(&desc, 0, sizeof(desc)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:674:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(&desc, 0, sizeof(desc)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:1139:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] ret = 0; /* ucsi_send_command() returns length on success */ ^ ~ drivers/usb/typec/ucsi/ucsi.c:1139:2: note: Value stored to 'ret' is never read ret = 0; /* ucsi_send_command() returns length on success */ ^ ~ drivers/usb/typec/ucsi/ucsi.c:1290:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(&ucsi->cap, 0, sizeof(ucsi->cap)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/usb/typec/ucsi/ucsi.c:1290:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(&ucsi->cap, 0, sizeof(ucsi->cap)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ Suppressed 22 warnings (22 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. 44 warnings generated. fs/cachefiles/cache.c:205:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(&stats, 0, sizeof(stats)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ fs/cachefiles/cache.c:205:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(&stats, 0, sizeof(stats)); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ Suppressed 43 warnings (43 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. 423 warnings generated. fs/btrfs/super.c:96:2: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memcpy(curr, STATE_STRING_PREFACE, sizeof(STATE_STRING_PREFACE)); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^~~~~~~~~~~~~~~~ fs/btrfs/super.c:96:2: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 memcpy(curr, STATE_STRING_PREFACE, sizeof(STATE_STRING_PREFACE)); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^~~~~~~~~~~~~~~~ fs/btrfs/super.c:279:4: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memcpy(lvl, fmt, size); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^~~~~~~~~~~~~~~~ fs/btrfs/super.c:279:4: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 memcpy(lvl, fmt, size); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^~~~~~~~~~~~~~~~ fs/btrfs/super.c:1349:3: warning: Call to function 'memmove' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memmove_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memmove(name, ptr, name + PATH_MAX - ptr); ^~~~~~~ fs/btrfs/super.c:1349:3: note: Call to function 'memmove' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memmove_s' in case of C11 memmove(name, ptr, name + PATH_MAX - ptr); ^~~~~~~ fs/btrfs/super.c:1792:3: warning: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); ^~~~~~~~ fs/btrfs/super.c:1792:3: note: Call to function 'snprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'snprintf_s' in case of C11 snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); ^~~~~~~~ Suppressed 419 warnings (419 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. 23 warnings generated. >> drivers/pwm/pwm-fsl-ftm.c:128:2: warning: Division by zero [clang-analyzer-core.DivideZero] do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:33:21: note: expanded from macro 'do_div' __upper = __high % (__base); \ ^ drivers/pwm/pwm-fsl-ftm.c:318:6: note: Assuming field 'enabled' is true if (!newstate->enabled) { ^~~~~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:318:2: note: Taking false branch if (!newstate->enabled) { ^ drivers/pwm/pwm-fsl-ftm.c:329:8: note: Calling 'fsl_pwm_apply_config' ret = fsl_pwm_apply_config(fpc, pwm, newstate); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:238:2: note: Taking false branch if (!fsl_pwm_calculate_period(fpc, newstate->period, &periodcfg)) { ^ drivers/pwm/pwm-fsl-ftm.c:243:2: note: Taking false branch if (!fsl_pwm_is_any_pwm_enabled(fpc, pwm)) ^ drivers/pwm/pwm-fsl-ftm.c:251:7: note: Taking false branch else if (!fsl_pwm_periodcfg_are_equal(&fpc->period, &periodcfg)) { ^ drivers/pwm/pwm-fsl-ftm.c:273:6: note: 'do_write_period' is false if (do_write_period) { ^~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:273:2: note: Taking false branch if (do_write_period) { ^ drivers/pwm/pwm-fsl-ftm.c:283:9: note: Calling 'fsl_pwm_calculate_duty' duty = fsl_pwm_calculate_duty(fpc, newstate->duty_cycle); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:196:27: note: Calling 'fsl_pwm_ticks_to_ns' unsigned int period_ns = fsl_pwm_ticks_to_ns(fpc, period); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:128:2: note: The value 0 is assigned to '__base' do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:25:2: note: expanded from macro 'do_div' __base = (base); \ ^~~~~~~~~~~~~~~ drivers/pwm/pwm-fsl-ftm.c:128:2: note: Left side of '&&' is false do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:26:35: note: expanded from macro 'do_div' if (__builtin_constant_p(__base) && is_power_of_2(__base)) { \ ^ drivers/pwm/pwm-fsl-ftm.c:128:2: note: Assuming '__high' is not equal to 0 do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:32:7: note: expanded from macro 'do_div' if (__high) { \ ^~~~~~ drivers/pwm/pwm-fsl-ftm.c:128:2: note: Taking true branch do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:32:3: note: expanded from macro 'do_div' if (__high) { \ ^ drivers/pwm/pwm-fsl-ftm.c:128:2: note: Division by zero do_div(exval, rate >> fpc->period.clk_ps); ^ arch/x86/include/asm/div64.h:33:21: note: expanded from macro 'do_div' __upper = __high % (__base); \ ~~~~~~~^~~~~~~~~~ Suppressed 22 warnings (22 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. 40 warnings generated. drivers/of/address.c:89:2: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(addr, 0, na * 4); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/of/address.c:89:2: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(addr, 0, na * 4); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/of/address.c:430:3: warning: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memset(addr, 0, pna * 4); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/of/address.c:430:3: note: Call to function 'memset' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memset_s' in case of C11 memset(addr, 0, pna * 4); ^ arch/x86/include/asm/string_32.h:195:29: note: expanded from macro 'memset' #define memset(s, c, count) __builtin_memset(s, c, count) ^~~~~~~~~~~~~~~~ drivers/of/address.c:449:2: warning: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling] memcpy(addr, ranges + na, 4 * pna); ^ arch/x86/include/asm/string_32.h:150:25: note: expanded from macro 'memcpy' #define memcpy(t, f, n) __builtin_memcpy(t, f, n) ^~~~~~~~~~~~~~~~ drivers/of/address.c:449:2: note: Call to function 'memcpy' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memcpy_s' in case of C11 memcpy(addr, ranges + na, 4 * pna); vim +128 drivers/pwm/pwm-fsl-ftm.c b505183b5117ce Xiubo Li 2014-02-27 118 3479bbd1e1f873 Patrick Havelange 2019-06-12 119 static unsigned int fsl_pwm_ticks_to_ns(struct fsl_pwm_chip *fpc, 3479bbd1e1f873 Patrick Havelange 2019-06-12 120 unsigned int ticks) b505183b5117ce Xiubo Li 2014-02-27 121 { 3479bbd1e1f873 Patrick Havelange 2019-06-12 122 unsigned long rate; 3479bbd1e1f873 Patrick Havelange 2019-06-12 123 unsigned long long exval; b505183b5117ce Xiubo Li 2014-02-27 124 3479bbd1e1f873 Patrick Havelange 2019-06-12 125 rate = clk_get_rate(fpc->clk[fpc->period.clk_select]); 3479bbd1e1f873 Patrick Havelange 2019-06-12 126 exval = ticks; 3479bbd1e1f873 Patrick Havelange 2019-06-12 127 exval *= 1000000000UL; 3479bbd1e1f873 Patrick Havelange 2019-06-12 @128 do_div(exval, rate >> fpc->period.clk_ps); 3479bbd1e1f873 Patrick Havelange 2019-06-12 129 return exval; b505183b5117ce Xiubo Li 2014-02-27 130 } b505183b5117ce Xiubo Li 2014-02-27 131 :::::: The code at line 128 was first introduced by commit :::::: 3479bbd1e1f873704b11a65ab7efcfb5fd9353de pwm: fsl-ftm: More relaxed permissions for updating period :::::: TO: Patrick Havelange :::::: CC: Thierry Reding -- 0-DAY CI Kernel Test Service https://01.org/lkp