Skip to content

Commit

Permalink
virtio-scsi: avoid cancelling uninitialized work items
Browse files Browse the repository at this point in the history
Calling the workqueue interface on uninitialized work items isn't a
good idea even if they're zeroed. It's not failing catastrophically only
through happy accidents.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Paolo Bonzini authored and Christoph Hellwig committed Jun 25, 2014
1 parent 7114aae commit cdda0e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/scsi/virtio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,16 @@ static void virtscsi_ctrl_done(struct virtqueue *vq)
virtscsi_vq_done(vscsi, &vscsi->ctrl_vq, virtscsi_complete_free);
};

static void virtscsi_handle_event(struct work_struct *work);

static int virtscsi_kick_event(struct virtio_scsi *vscsi,
struct virtio_scsi_event_node *event_node)
{
int err;
struct scatterlist sg;
unsigned long flags;

INIT_WORK(&event_node->work, virtscsi_handle_event);
sg_init_one(&sg, &event_node->event, sizeof(struct virtio_scsi_event));

spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
Expand Down Expand Up @@ -377,7 +380,6 @@ static void virtscsi_complete_event(struct virtio_scsi *vscsi, void *buf)
{
struct virtio_scsi_event_node *event_node = buf;

INIT_WORK(&event_node->work, virtscsi_handle_event);
schedule_work(&event_node->work);
}

Expand Down

0 comments on commit cdda0e5

Please sign in to comment.