mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 09/16] video: vpl: handle missing struct vpl::ioctl gracefully
Date: Thu,  5 Jun 2025 23:07:19 +0200	[thread overview]
Message-ID: <20250605210726.1916656-10-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250605210726.1916656-1-a.fatoum@barebox.org>

Display controllers don't usually implement the ioctl callback, because
they are invoked via the register_framebuffer API and only need to call
other drivers' ioctl and their own is never called.

Yet, when by mistake an ioctl is directed at a display controller, we
currently crash. Let's handle this case gracefully instead.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 drivers/video/vpl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/video/vpl.c b/drivers/video/vpl.c
index 0b86ef9f7e81..da8bd93b7d6a 100644
--- a/drivers/video/vpl.c
+++ b/drivers/video/vpl.c
@@ -106,6 +106,7 @@ static int vpl_foreach_endpoint(struct vpl *vpl, unsigned int port,
 }
 
 struct vpl_ioctl {
+	int err;
 	unsigned cmd;
 	void *ptr;
 };
@@ -114,6 +115,11 @@ static int vpl_remote_ioctl(struct vpl *vpl, unsigned port, void *_data)
 {
 	struct vpl_ioctl *data = _data;
 
+	if (!vpl->ioctl) {
+		data->err = -EOPNOTSUPP;
+		return 0;
+	}
+
 	return vpl->ioctl(vpl, port, data->cmd, data->ptr);
 }
 
@@ -122,5 +128,5 @@ int vpl_ioctl(struct vpl *vpl, unsigned int port,
 {
 	struct vpl_ioctl data = { .cmd = cmd, .ptr = ptr };
 
-	return vpl_foreach_endpoint(vpl, port, vpl_remote_ioctl, &data);
+	return vpl_foreach_endpoint(vpl, port, vpl_remote_ioctl, &data) ?: data.err;
 }
-- 
2.39.5




  parent reply	other threads:[~2025-06-05 21:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-05 21:07 [PATCH 00/16] ARM: stm32mp: add MIPI DSI support Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 01/16] driver: bus: embed bus driver node into bus Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 02/16] driver: switch busses to device class Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 03/16] driver: factor out bus definitions into separate header Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 04/16] driver: bus: add helpers for finding devices in busses Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 05/16] drive: bus: make use of new bus_find_device helper Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 06/16] of: implement of_alias_from_compatible Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 07/16] video: vpl: fix potential read of uninitialized variable Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 08/16] video: vpl: factor out vpl_for_each Ahmad Fatoum
2025-06-05 21:07 ` Ahmad Fatoum [this message]
2025-06-05 21:07 ` [PATCH 10/16] video: vpl: add vpl_bridge abstraction Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 11/16] video: factor out drm_mode_vrefresh Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 12/16] video: add base MIPI DSI support Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 13/16] video: add Designware MIPI-DSI support Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 14/16] video: add STM32 MIPI DSI video driver Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 15/16] video: add support for Orise Technology otm8009a panel Ahmad Fatoum
2025-06-05 21:07 ` [PATCH 16/16] ARM: stm32mp: dk2: enable MIPI-DSI display by default Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250605210726.1916656-10-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox