Skip to contentSkip to conversation

usb: ehci: add capability mmio write function

PATCH In review P J P 2 participants 3 messages Jan 29, 2016

lore
Share & tools
lore

P J P

author
#0 lore raw

PATCH 1/1 usb: ehci: add capability mmio write function

From: Prasad J Pandit <[email protected]>

USB Ehci emulation supports host controller capability registers. But its mmio '.write' function was missing, which lead to a null pointer dereference issue. Add a do nothing 'ehci_caps_write' definition to avoid it; Do nothing because capability registers are Read Only(RO).

---
 hw/usb/hcd-ehci.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/usb/hcd-ehci.c +6 -0
index c40013e..b08ff62 100644
@@ -893,6 +893,11 @@ static uint64_t ehci_caps_read(void *ptr, hwaddr addr,
     return s->caps[addr];
 }
 
+static void ehci_caps_write(void *ptr, hwaddr addr,
+                             uint64_t val, unsigned size)
+{
+}
+
 static uint64_t ehci_opreg_read(void *ptr, hwaddr addr,
                                 unsigned size)
 {
@@ -2313,6 +2318,7 @@ static void ehci_frame_timer(void *opaque)
 
 static const MemoryRegionOps ehci_mmio_caps_ops = {
     .read = ehci_caps_read,
+    .write = ehci_caps_write,
     .valid.min_access_size = 1,
     .valid.max_access_size = 4,
     .impl.min_access_size = 1,
Signature · 1 line
2.5.0
#1 lore raw
Quoted 7 lines · P J P

From: Prasad J Pandit <[email protected]>

USB Ehci emulation supports host controller capability registers. But its mmio '.write' function was missing, which lead to a null pointer dereference issue. Add a do nothing 'ehci_caps_write' definition to avoid it; Do nothing because capability registers are Read Only(RO).

Surely makes sense, xhci does the same, I'll pick it up.

Maybe we should have a generic nop_write function somewhere. Not that there can much go wrong by cut&pasting here, but still ...

cheers,
Gerd

author
#2 lore raw

Hello Gerd,

+-- On Fri, 29 Jan 2016, Gerd Hoffmann wrote --+
| On Fr, 2016-01-29 at 18:30 +0530, P J P wrote:
| > pointer dereference issue. Add a do nothing 'ehci_caps_write'
| > definition to avoid it; Do nothing because capability registers
| > are Read Only(RO).
| 
| Surely makes sense, xhci does the same, I'll pick it up.

Cool! Thank you.

| Maybe we should have a generic nop_write function somewhere. Not that there

True. Would one nop_write function serve them all? I mean do they share the
same prototype/syntax?

--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F