tablet: fix unexpected termination issue
authorJinhyung Jo <jinhyung.jo@samsung.com>
Mon, 5 Sep 2016 09:52:34 +0000 (18:52 +0900)
committerJinhyung Jo <jinhyung.jo@samsung.com>
Tue, 6 Sep 2016 05:42:47 +0000 (14:42 +0900)
'Null Pointer Dereference' occurs, the emulator dies unexpectedly.
It is caused by commit f998ca30b51b5c549898763d4bd5041380a60416.
The committer have made a mistake when applying the virtio API modification.
The virtio API has been changed as follows:
    previous: int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
    current: void *virtqueue_pop(VirtQueue *vq, size_t sz)

Change-Id: I2c5a20c2741633f855ab0128f7e4dd989404b2b2
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
tizen/src/hw/virtio/maru_virtio_tablet.c

index 9a564ba..5bab39c 100644 (file)
@@ -148,9 +148,7 @@ static void maru_tablet_bh(void *opaque)
     qemu_mutex_unlock(&vt->mutex);
 
     /* Get a queue buffer which is written by guest side. */
-    do {
-        elem = virtqueue_pop(vt->vq, sizeof(VirtQueueElement));
-    } while (elem);
+    elem = virtqueue_pop(vt->vq, sizeof(VirtQueueElement));
 
     qemu_mutex_lock(&vt->mutex);
     while (!QTAILQ_EMPTY(&events_queue)) {
@@ -160,10 +158,10 @@ static void maru_tablet_bh(void *opaque)
         /* copy event into virtio buffer */
         len = iov_from_buf(elem->in_sg, elem->in_num, push_len,
                            &(event_entry->tablet), sizeof(EmulTabletEvent));
-        if(len != sizeof(EmulTabletEvent)) {
+        if (len != sizeof(EmulTabletEvent)) {
             LOG_WARNING("len != sizeof(EmulTabletEvent).\n");
             LOG_WARNING("len: %zu, sizeof(EmulTabletEvent): %zu\n",
-                            len, sizeof(EmulTabletEvent));
+                        len, sizeof(EmulTabletEvent));
         }
         push_len += sizeof(EmulTabletEvent);