diff mbox

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

Message ID 1272626035-14416-1-git-send-email-amit.shah@redhat.com
State New
Headers show

Commit Message

Amit Shah April 30, 2010, 11:13 a.m. UTC
In the flush_queued_data() function, we expect port to be valid. Assert
only for port and not port || discard.

Reported-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Juan Quintela April 30, 2010, 1:50 p.m. UTC | #1
Amit Shah <amit.shah@redhat.com> wrote:
> In the flush_queued_data() function, we expect port to be valid. Assert
> only for port and not port || discard.
>
> Reported-by: Juan Quintela <quintela@redhat.com>
> Signed-off-by: Amit Shah <amit.shah@redhat.com>

reviewed-by: Juan Quintela <quintela@redhat.com>

> ---
>  hw/virtio-serial-bus.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 97694d5..3ce95e8 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -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);
>  }
Anthony Liguori May 3, 2010, 5:14 p.m. UTC | #2
On 04/30/2010 06:13 AM, Amit Shah wrote:
> In the flush_queued_data() function, we expect port to be valid. Assert
> only for port and not port || discard.
>
> Reported-by: Juan Quintela<quintela@redhat.com>
> Signed-off-by: Amit Shah<amit.shah@redhat.com>
>    

Applied.  Thanks.

Regards,

Anthony Liguori
> ---
>   hw/virtio-serial-bus.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 97694d5..3ce95e8 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -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);
>   }
>
diff mbox

Patch

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 97694d5..3ce95e8 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -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);
 }