mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] virtio_console: fix endian conversion in handle_control_message()
@ 2026-06-23  9:21 Ben Dooks
  2026-06-23  9:28 ` Arnd Bergmann
  2026-06-23 12:23 ` Amit Shah
  0 siblings, 2 replies; 3+ messages in thread
From: Ben Dooks @ 2026-06-23  9:21 UTC (permalink / raw)
  To: Amit Shah, Arnd Bergmann, Greg Kroah-Hartman, virtualization,
	linux-kernel
  Cc: Ben Dooks

There are a couple of prints in handle_control_message() which should
have converted cpkt->id through virtio32_to_cpu() before passing to
a print.

This fixes the following (prototype) sparse warnings:
drivers/char/virtio_console.c:1538:17: warning: incorrect type in argument 4 (different base types)
drivers/char/virtio_console.c:1538:17:    expected unsigned int
drivers/char/virtio_console.c:1538:17:    got restricted __virtio32 [usertype] id
drivers/char/virtio_console.c:1553:25: warning: incorrect type in argument 3 (different base types)
drivers/char/virtio_console.c:1553:25:    expected unsigned int
drivers/char/virtio_console.c:1553:25:    got restricted __virtio32 [usertype] id

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
 drivers/char/virtio_console.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 198b97314168..cbdc497f5160 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1536,7 +1536,8 @@ static void handle_control_message(struct virtio_device *vdev,
 	    cpkt->event != cpu_to_virtio16(vdev, VIRTIO_CONSOLE_PORT_ADD)) {
 		/* No valid header at start of buffer.  Drop it. */
 		dev_dbg(&portdev->vdev->dev,
-			"Invalid index %u in control packet\n", cpkt->id);
+			"Invalid index %u in control packet\n",
+			virtio32_to_cpu(vdev, cpkt->id));
 		return;
 	}
 
@@ -1553,7 +1554,8 @@ static void handle_control_message(struct virtio_device *vdev,
 			dev_warn(&portdev->vdev->dev,
 				"Request for adding port with "
 				"out-of-bound id %u, max. supported id: %u\n",
-				cpkt->id, portdev->max_nr_ports - 1);
+				 virtio32_to_cpu(vdev, cpkt->id),
+				 portdev->max_nr_ports - 1);
 			break;
 		}
 		add_port(portdev, virtio32_to_cpu(vdev, cpkt->id));
-- 
2.37.2.352.g3c44437643


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_console: fix endian conversion in handle_control_message()
  2026-06-23  9:21 [PATCH] virtio_console: fix endian conversion in handle_control_message() Ben Dooks
@ 2026-06-23  9:28 ` Arnd Bergmann
  2026-06-23 12:23 ` Amit Shah
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2026-06-23  9:28 UTC (permalink / raw)
  To: Ben Dooks, Amit Shah, Greg Kroah-Hartman, virtualization, linux-kernel

On Tue, Jun 23, 2026, at 11:21, Ben Dooks wrote:
> There are a couple of prints in handle_control_message() which should
> have converted cpkt->id through virtio32_to_cpu() before passing to
> a print.
>
> This fixes the following (prototype) sparse warnings:
> drivers/char/virtio_console.c:1538:17: warning: incorrect type in 
> argument 4 (different base types)
> drivers/char/virtio_console.c:1538:17:    expected unsigned int
> drivers/char/virtio_console.c:1538:17:    got restricted __virtio32 
> [usertype] id
> drivers/char/virtio_console.c:1553:25: warning: incorrect type in 
> argument 3 (different base types)
> drivers/char/virtio_console.c:1553:25:    expected unsigned int
> drivers/char/virtio_console.c:1553:25:    got restricted __virtio32 
> [usertype] id
>
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] virtio_console: fix endian conversion in handle_control_message()
  2026-06-23  9:21 [PATCH] virtio_console: fix endian conversion in handle_control_message() Ben Dooks
  2026-06-23  9:28 ` Arnd Bergmann
@ 2026-06-23 12:23 ` Amit Shah
  1 sibling, 0 replies; 3+ messages in thread
From: Amit Shah @ 2026-06-23 12:23 UTC (permalink / raw)
  To: Ben Dooks, Arnd Bergmann, Greg Kroah-Hartman, virtualization,
	linux-kernel

On Tue, 2026-06-23 at 10:21 +0100, Ben Dooks wrote:
> There are a couple of prints in handle_control_message() which should
> have converted cpkt->id through virtio32_to_cpu() before passing to
> a print.
> 
> This fixes the following (prototype) sparse warnings:
> drivers/char/virtio_console.c:1538:17: warning: incorrect type in
> argument 4 (different base types)
> drivers/char/virtio_console.c:1538:17:    expected unsigned int
> drivers/char/virtio_console.c:1538:17:    got restricted __virtio32
> [usertype] id
> drivers/char/virtio_console.c:1553:25: warning: incorrect type in
> argument 3 (different base types)
> drivers/char/virtio_console.c:1553:25:    expected unsigned int
> drivers/char/virtio_console.c:1553:25:    got restricted __virtio32
> [usertype] id
> 
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>

Reviewed-by: Amit Shah <amit@kernel.org>

		Amit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-23 12:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-23  9:21 [PATCH] virtio_console: fix endian conversion in handle_control_message() Ben Dooks
2026-06-23  9:28 ` Arnd Bergmann
2026-06-23 12:23 ` Amit Shah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®