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

login
register
mail settings
Submitter Amit Shah
Date April 30, 2010, 11:13 a.m.
Message ID <1272626035-14416-1-git-send-email-amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/51325/
State New
Headers show

Comments

Amit Shah - April 30, 2010, 11:13 a.m.
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(-)
Juan Quintela - April 30, 2010, 1:50 p.m.
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.
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);
>   }
>

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);
 }