Skip to contentSkip to conversation

virtio-serial: Fix check for 'assert'; prevent NULL derefs

PATCH Applied Amit Shah 3 participants 3 messages Apr 30, 2010 – May 3, 2010

lore
Share & tools
lore

Amit Shah

author
#0 lore raw

PATCH 1/1 virtio-serial: Fix check for 'assert'; prevent NULL derefs

In the flush_queued_data() function, we expect port to be valid. Assert only for port and not port || discard.

---
 hw/virtio-serial-bus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-serial-bus.c +1 -1
index 97694d5..3ce95e8 100644
@@ -137,7 +137,7 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
 
 static void flush_queued_data(VirtIOSerialPort *port, bool discard)
 {
-    assert(port || discard);
+    assert(port);
 
     do_flush_queued_data(port, port->ovq, &port->vser->vdev, discard);
 }
Signature · 1 line
1.6.2.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Amit Shah

In the flush_queued_data() function, we expect port to be valid. Assert only for port and not port || discard.

Quoted 17 lines
---
 hw/virtio-serial-bus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-serial-bus.c +1 -1
index 97694d5..3ce95e8 100644
@@ -137,7 +137,7 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
 
 static void flush_queued_data(VirtIOSerialPort *port, bool discard)
 {
-    assert(port || discard);
+    assert(port);
 
     do_flush_queued_data(port, port->ovq, &port->vser->vdev, discard);
 }
#2 lore raw
In reply to Amit Shah
Quoted 6 lines · Amit Shah

In the flush_queued_data() function, we expect port to be valid. Assert only for port and not port || discard.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 18 lines
---
  hw/virtio-serial-bus.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
hw/virtio-serial-bus.c +1 -1
index 97694d5..3ce95e8 100644
@@ -137,7 +137,7 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
 
  static void flush_queued_data(VirtIOSerialPort *port, bool discard)
  {
-    assert(port || discard);
+    assert(port);
 
      do_flush_queued_data(port, port->ovq,&port->vser->vdev, discard);
  }