hw/omap_intc.c: Avoid crash on access to nonexistent banked registers
PATCH 1/1 hw/omap_intc.c: Avoid crash on access to nonexistent banked registers
Avoid a crash due to null pointer dereference if a guest attempts to access banked registers for a nonexistent bank. Spotted by Coverity (see bug 887883).
Signed-off-by Peter Maydell <[email protected]>
--- hw/omap_intc.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
hw/omap_intc.c +6 -0
@@ -398,6 +398,9 @@ static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,if (bank_no < s->nbanks) { offset &= ~0x60 ; bank = &s->bank[bank_no]; + }else { +OMAP_BAD_REG (addr); +return 0 ; } }
@@ -476,6 +479,9 @@ static void omap2_inth_write(void *opaque, target_phys_addr_t addr,if (bank_no < s->nbanks) { offset &= ~0x60 ; bank = &s->bank[bank_no]; + }else { +OMAP_BAD_REG (addr); +return ; } }
Signature · 1 line
1.7.1
Anthony Liguori
AppliedQuoted 5 lines · Peter Maydell
Avoid a crash due to null pointer dereference if a guest attempts to access banked registers for a nonexistent bank. Spotted by Coverity (see bug 887883).
Signed-off-by Peter Maydell<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 28 lines
--- hw/omap_intc.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)hw/omap_intc.c +6
-0@@ -398,6 +398,9 @@ static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,if (bank_no< s->nbanks) { offset&= ~0x60 ; bank =&s->bank[bank_no]; + }else { +OMAP_BAD_REG (addr); +return 0 ; } }@@ -476,6 +479,9 @@ static void omap2_inth_write(void *opaque, target_phys_addr_t addr,if (bank_no< s->nbanks) { offset&= ~0x60 ; bank =&s->bank[bank_no]; + }else { +OMAP_BAD_REG (addr); +return ; } }