Skip to content

Commit 23ef731

Browse files
kirylhansendc
authored andcommitted
x86/insn-eval: Handle insn_get_opcode() failure
is_string_insn() calls insn_get_opcode() that can fail, but does not handle the failure. is_string_insn() interface does not allow to communicate an error to the caller. Push insn_get_opcode() to the only non-static user of is_string_insn() and fail it early if insn_get_opcode() fails. [ dhansen: fix tabs-versus-spaces breakage ] Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Tested-by: Joerg Roedel <[email protected]> Acked-by: Tom Lendacky <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d58071a commit 23ef731

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/lib/insn-eval.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ enum reg_type {
3737
*/
3838
static bool is_string_insn(struct insn *insn)
3939
{
40-
insn_get_opcode(insn);
41-
4240
/* All string instructions have a 1-byte opcode. */
4341
if (insn->opcode.nbytes != 1)
4442
return false;
@@ -1405,6 +1403,9 @@ void __user *insn_get_addr_ref(struct insn *insn, struct pt_regs *regs)
14051403
if (!insn || !regs)
14061404
return (void __user *)-1L;
14071405

1406+
if (insn_get_opcode(insn))
1407+
return (void __user *)-1L;
1408+
14081409
switch (insn->addr_bytes) {
14091410
case 2:
14101411
return get_addr_ref_16(insn, regs);

0 commit comments

Comments
 (0)