提交 70670444 编写于 作者: R Rusty Russell

virtio: fail adding buffer on broken queues.

Heinz points out that adding buffers to a broken virtqueue (which
should "never happen") still works.  Failing allows drivers to detect
and complain about broken devices.

Now drivers are robust, we can add this extra check.
Reported-by: NHeinz Graalfs <graalfs@linux.vnet.ibm.com>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
上级 9914a766
...@@ -204,6 +204,11 @@ static inline int virtqueue_add(struct virtqueue *_vq, ...@@ -204,6 +204,11 @@ static inline int virtqueue_add(struct virtqueue *_vq,
BUG_ON(data == NULL); BUG_ON(data == NULL);
if (unlikely(vq->broken)) {
END_USE(vq);
return -EIO;
}
#ifdef DEBUG #ifdef DEBUG
{ {
ktime_t now = ktime_get(); ktime_t now = ktime_get();
...@@ -310,7 +315,7 @@ static inline int virtqueue_add(struct virtqueue *_vq, ...@@ -310,7 +315,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
* Caller must ensure we don't call this with other virtqueue operations * Caller must ensure we don't call this with other virtqueue operations
* at the same time (except where noted). * at the same time (except where noted).
* *
* Returns zero or a negative error (ie. ENOSPC, ENOMEM). * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
*/ */
int virtqueue_add_sgs(struct virtqueue *_vq, int virtqueue_add_sgs(struct virtqueue *_vq,
struct scatterlist *sgs[], struct scatterlist *sgs[],
...@@ -348,7 +353,7 @@ EXPORT_SYMBOL_GPL(virtqueue_add_sgs); ...@@ -348,7 +353,7 @@ EXPORT_SYMBOL_GPL(virtqueue_add_sgs);
* Caller must ensure we don't call this with other virtqueue operations * Caller must ensure we don't call this with other virtqueue operations
* at the same time (except where noted). * at the same time (except where noted).
* *
* Returns zero or a negative error (ie. ENOSPC, ENOMEM). * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
*/ */
int virtqueue_add_outbuf(struct virtqueue *vq, int virtqueue_add_outbuf(struct virtqueue *vq,
struct scatterlist sg[], unsigned int num, struct scatterlist sg[], unsigned int num,
...@@ -370,7 +375,7 @@ EXPORT_SYMBOL_GPL(virtqueue_add_outbuf); ...@@ -370,7 +375,7 @@ EXPORT_SYMBOL_GPL(virtqueue_add_outbuf);
* Caller must ensure we don't call this with other virtqueue operations * Caller must ensure we don't call this with other virtqueue operations
* at the same time (except where noted). * at the same time (except where noted).
* *
* Returns zero or a negative error (ie. ENOSPC, ENOMEM). * Returns zero or a negative error (ie. ENOSPC, ENOMEM, EIO).
*/ */
int virtqueue_add_inbuf(struct virtqueue *vq, int virtqueue_add_inbuf(struct virtqueue *vq,
struct scatterlist sg[], unsigned int num, struct scatterlist sg[], unsigned int num,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册