Commit 2ff49881 authored by Borislav Petkov's avatar Borislav Petkov
Browse files

perf/x86/intel/ds: Check insn_get_length() retval



intel_pmu_pebs_fixup_ip() needs only the insn length so use the
appropriate helper instead of a full decode. A full decode differs only
in running insn_complete() on the decoded insn but that is not needed
here.

Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210304174237.31945-8-bp@alien8.de
parent 514ef776
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1353,14 +1353,13 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs)
		is_64bit = kernel_ip(to) || any_64bit_mode(regs);
#endif
		insn_init(&insn, kaddr, size, is_64bit);
		insn_get_length(&insn);

		/*
		 * Make sure there was not a problem decoding the
		 * instruction and getting the length.  This is
		 * doubly important because we have an infinite
		 * loop if insn.length=0.
		 * Make sure there was not a problem decoding the instruction.
		 * This is doubly important because we have an infinite loop if
		 * insn.length=0.
		 */
		if (!insn.length)
		if (insn_get_length(&insn))
			break;

		to += insn.length;