2020-02-14 08:02:03

by Gerd Hoffmann

[permalink] [raw]
Subject: [PATCH] drm/virtio: fix error check

The >= compare op must happen in cpu byte order, doing it in
little endian fails on big endian machines like s390.

Reported-by: Sebastian Mitterle <[email protected]>
Signed-off-by: Gerd Hoffmann <[email protected]>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index cfe9c54f87a3..67caecde623e 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -222,7 +222,7 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
trace_virtio_gpu_cmd_response(vgdev->ctrlq.vq, resp);

if (resp->type != cpu_to_le32(VIRTIO_GPU_RESP_OK_NODATA)) {
- if (resp->type >= cpu_to_le32(VIRTIO_GPU_RESP_ERR_UNSPEC)) {
+ if (le32_to_cpu(resp->type) >= VIRTIO_GPU_RESP_ERR_UNSPEC) {
struct virtio_gpu_ctrl_hdr *cmd;
cmd = virtio_gpu_vbuf_ctrl_hdr(entry);
DRM_ERROR_RATELIMITED("response 0x%x (command 0x%x)\n",
--
2.18.2


2020-02-14 08:59:14

by Cornelia Huck

[permalink] [raw]
Subject: Re: [PATCH] drm/virtio: fix error check

On Fri, 14 Feb 2020 09:01:00 +0100
Gerd Hoffmann <[email protected]> wrote:

> The >= compare op must happen in cpu byte order, doing it in
> little endian fails on big endian machines like s390.
>
> Reported-by: Sebastian Mitterle <[email protected]>
> Signed-off-by: Gerd Hoffmann <[email protected]>
> ---
> drivers/gpu/drm/virtio/virtgpu_vq.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index cfe9c54f87a3..67caecde623e 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -222,7 +222,7 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
> trace_virtio_gpu_cmd_response(vgdev->ctrlq.vq, resp);
>
> if (resp->type != cpu_to_le32(VIRTIO_GPU_RESP_OK_NODATA)) {
> - if (resp->type >= cpu_to_le32(VIRTIO_GPU_RESP_ERR_UNSPEC)) {
> + if (le32_to_cpu(resp->type) >= VIRTIO_GPU_RESP_ERR_UNSPEC) {
> struct virtio_gpu_ctrl_hdr *cmd;
> cmd = virtio_gpu_vbuf_ctrl_hdr(entry);
> DRM_ERROR_RATELIMITED("response 0x%x (command 0x%x)\n",

Reviewed-by: Cornelia Huck <[email protected]>

Endianness continues to be fun.