Skip to content

Commit

Permalink
s390/dis: use explicit buf len
Browse files Browse the repository at this point in the history
Pass buffer length in extra parameter.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
  • Loading branch information
Stefan Raspl authored and Martin Schwidefsky committed Apr 17, 2013
1 parent 08b4212 commit 0bcc94b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion arch/s390/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ extern unsigned long thread_saved_pc(struct task_struct *t);

extern void show_code(struct pt_regs *regs);
extern void print_fn_code(unsigned char *code, unsigned long len);
extern int insn_to_mnemonic(unsigned char *instruction, char buf[8]);
extern int insn_to_mnemonic(unsigned char *instruction, char *buf,
unsigned int len);

unsigned long get_wchan(struct task_struct *p);
#define task_pt_regs(tsk) ((struct pt_regs *) \
Expand Down
9 changes: 5 additions & 4 deletions arch/s390/kernel/dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1696,25 +1696,26 @@ static struct insn *find_insn(unsigned char *code)
* insn_to_mnemonic - decode an s390 instruction
* @instruction: instruction to decode
* @buf: buffer to fill with mnemonic
* @len: length of buffer
*
* Decode the instruction at @instruction and store the corresponding
* mnemonic into @buf.
* mnemonic into @buf of length @len.
* @buf is left unchanged if the instruction could not be decoded.
* Returns:
* %0 on success, %-ENOENT if the instruction was not found.
*/
int insn_to_mnemonic(unsigned char *instruction, char buf[8])
int insn_to_mnemonic(unsigned char *instruction, char *buf, unsigned int len)
{
struct insn *insn;

insn = find_insn(instruction);
if (!insn)
return -ENOENT;
if (insn->name[0] == '\0')
snprintf(buf, 8, "%s",
snprintf(buf, len, "%s",
long_insn_name[(int) insn->name[1]]);
else
snprintf(buf, 8, "%.5s", insn->name);
snprintf(buf, len, "%.5s", insn->name);
return 0;
}
EXPORT_SYMBOL_GPL(insn_to_mnemonic);
Expand Down
2 changes: 1 addition & 1 deletion arch/s390/kvm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ TRACE_EVENT(kvm_s390_intercept_instruction,
__entry->instruction,
insn_to_mnemonic((unsigned char *)
&__entry->instruction,
__entry->insn) ?
__entry->insn, sizeof(__entry->insn)) ?
"unknown" : __entry->insn)
);

Expand Down

0 comments on commit 0bcc94b

Please sign in to comment.