]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/xmon: Fix whitespace handling in getstring()
authorOliver O'Halloran <oohall@gmail.com>
Mon, 17 Feb 2020 04:13:43 +0000 (15:13 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 18 Feb 2020 10:31:12 +0000 (21:31 +1100)
commit4980a341d2611cb8fe05f1ebcb4e9f8cb35709a2
tree81c5186d16ec98897564d4a084f6602229e6e089
parent80e0437cdbc284cd00f6781c8b6528dc731e4255
powerpc/xmon: Fix whitespace handling in getstring()

The ls (lookup symbol) and zr (reboot) commands use xmon's getstring()
helper to read a string argument from the xmon prompt. This function
skips over leading whitespace, but doesn't check if the first
"non-whitespace" character is a newline which causes some odd
behaviour (<enter> indicates a the enter key was pressed):

  0:mon> ls printk<enter>
  printk: c0000000001680c4

  0:mon> ls<enter>
  printk<enter>
  Symbol '
  printk' not found.
  0:mon>

With commit fe126b28f68 ("powerpc/xmon: Allow passing an argument to
ppc_md.restart()") we have a similar problem with the zr command.
Previously zr took no arguments so "zr<enter> would trigger a reboot.
With that patch applied a second newline needs to be sent in order for
the reboot to occur. Fix this by checking if the leading whitespace
ended on a newline:

  0:mon> ls<enter>
  Symbol '' not found.

Fixes: fe126b28f681 ("powerpc/xmon: Allow passing an argument to ppc_md.restart()")
Reported-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200217041343.2454-1-oohall@gmail.com
arch/powerpc/xmon/xmon.c