Messages in this thread | | | Date | Fri, 7 Aug 2020 00:33:42 +0800 | From | kernel test robot <> | Subject | arch/x86/net/bpf_jit_comp.c:342:6: warning: Variable 'ret' is reassigned a value before the old one has been used. |
| |
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 47ec5303d73ea344e84f46660fff693c57641386 commit: 428d5df1fa4f28daf622c48dd19da35585c9053c bpf, x86: Emit patchable direct jump as tail call date: 9 months ago compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com>
cppcheck warnings: (new ones prefixed by >>)
>> arch/x86/net/bpf_jit_comp.c:342:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment] ret = 0; ^ arch/x86/net/bpf_jit_comp.c:334:6: note: Variable 'ret' is reassigned a value before the old one has been used. ret = -EBUSY; ^ arch/x86/net/bpf_jit_comp.c:342:6: note: Variable 'ret' is reassigned a value before the old one has been used. ret = 0; ^ arch/x86/net/bpf_jit_comp.c:409:2: warning: Signed integer overflow for expression '72+(139<<8)+(132<<16)+(214<<24)'. [integerOverflow] EMIT4_off32(0x48, 0x8B, 0x84, 0xD6, /* mov rax, [rsi + rdx * 8 + offsetof(...)] */ ^
vim +/ret +342 arch/x86/net/bpf_jit_comp.c
267 268 static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t, 269 void *old_addr, void *new_addr, 270 const bool text_live) 271 { 272 int (*emit_patch_fn)(u8 **pprog, void *func, void *ip); 273 const u8 *nop_insn = ideal_nops[NOP_ATOMIC5]; 274 u8 old_insn[X86_PATCH_SIZE] = {}; 275 u8 new_insn[X86_PATCH_SIZE] = {}; 276 u8 *prog; 277 int ret; 278 279 switch (t) { 280 case BPF_MOD_NOP_TO_CALL ... BPF_MOD_CALL_TO_NOP: 281 emit_patch_fn = emit_call; 282 break; 283 case BPF_MOD_NOP_TO_JUMP ... BPF_MOD_JUMP_TO_NOP: 284 emit_patch_fn = emit_jump; 285 break; 286 default: 287 return -ENOTSUPP; 288 } 289 290 switch (t) { 291 case BPF_MOD_NOP_TO_CALL: 292 case BPF_MOD_NOP_TO_JUMP: 293 if (!old_addr && new_addr) { 294 memcpy(old_insn, nop_insn, X86_PATCH_SIZE); 295 296 prog = new_insn; 297 ret = emit_patch_fn(&prog, new_addr, ip); 298 if (ret) 299 return ret; 300 break; 301 } 302 return -ENXIO; 303 case BPF_MOD_CALL_TO_CALL: 304 case BPF_MOD_JUMP_TO_JUMP: 305 if (old_addr && new_addr) { 306 prog = old_insn; 307 ret = emit_patch_fn(&prog, old_addr, ip); 308 if (ret) 309 return ret; 310 311 prog = new_insn; 312 ret = emit_patch_fn(&prog, new_addr, ip); 313 if (ret) 314 return ret; 315 break; 316 } 317 return -ENXIO; 318 case BPF_MOD_CALL_TO_NOP: 319 case BPF_MOD_JUMP_TO_NOP: 320 if (old_addr && !new_addr) { 321 memcpy(new_insn, nop_insn, X86_PATCH_SIZE); 322 323 prog = old_insn; 324 ret = emit_patch_fn(&prog, old_addr, ip); 325 if (ret) 326 return ret; 327 break; 328 } 329 return -ENXIO; 330 default: 331 return -ENOTSUPP; 332 } 333 334 ret = -EBUSY; 335 mutex_lock(&text_mutex); 336 if (memcmp(ip, old_insn, X86_PATCH_SIZE)) 337 goto out; 338 if (text_live) 339 text_poke_bp(ip, new_insn, X86_PATCH_SIZE, NULL); 340 else 341 memcpy(ip, new_insn, X86_PATCH_SIZE); > 342 ret = 0; 343 out: 344 mutex_unlock(&text_mutex); 345 return ret; 346 } 347
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
| |