From 1387e7c7c21de29b472264b322624088ed61c815 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Wed, 28 Oct 2020 11:50:56 -0700 Subject: [PATCH] scripts: coredump: fix crashing on non-existent memory region get_mem_region() may return None for a non-existent memory region so we need to check first before looking at its properties. Signed-off-by: Daniel Leung --- scripts/coredump/gdbstubs/gdbstub.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/coredump/gdbstubs/gdbstub.py b/scripts/coredump/gdbstubs/gdbstub.py index 23b9d57c875..60f332851c3 100644 --- a/scripts/coredump/gdbstubs/gdbstub.py +++ b/scripts/coredump/gdbstubs/gdbstub.py @@ -139,13 +139,14 @@ class GdbStub(abc.ABC): barray = b'' r = get_mem_region(addr) while remaining > 0: - if addr > r['end']: - r = get_mem_region(addr) - if r is None: barray = None break + if addr > r['end']: + r = get_mem_region(addr) + continue + offset = addr - r['start'] barray += r['data'][offset:offset+1]