public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	Alexei Starovoitov <ast@kernel.org>
Subject: arch/x86/net/bpf_jit_comp.c:342:6: warning: Variable 'ret' is reassigned a value before the old one has been used.
Date: Fri, 7 Aug 2020 00:33:42 +0800	[thread overview]
Message-ID: <202008070037.Dz0HMdFX%lkp@intel.com> (raw)

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

                 reply	other threads:[~2020-08-06 17:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202008070037.Dz0HMdFX%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox