* [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init()
@ 2026-09-26 13:16 Lorenzo Stoakes (ARM)
2026-09-26 13:16 ` [PATCH 1/6] fbdev: ssd1307fb: check for fb_deferred_io_init() error Lorenzo Stoakes (ARM)
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:16 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
Commit 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
converted fb_deferred_io_init() from a void function to one returning an
error value.
However a number of callers don't seem to have been apprised of the fact
and continue to treat it like a void function.
This is problematic, as upon allocation failure, struct
fb_info->fbdefio_state is NULL.
That means when a subsequent operation is performed upon the driver, for
instance opening the file, a NULL pointer dereference occurs.
Update all of the remaining drivers which fail to check this to do so.
This issue was discovered as part of a separate series which updated logic
belonging to ssd1307fb.
Also fix up a separate issue with a BUG_ON() occurring on allocation
failure for udlfb and smcufx.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
Lorenzo Stoakes (ARM) (6):
fbdev: ssd1307fb: check for fb_deferred_io_init() error
fbdev: xen-fbfront: check for fb_deferred_io_init() error
HID: picoLCD: check for fb_deferred_io_init() error
fbdev: udlfb: check for fb_deferred_io_init() error
fbdev: smscufx: check for fb_deferred_io_init() error
fbdev: sh_mobile_lcdc: check for fb_deferred_io_init() error
drivers/hid/hid-picolcd_fb.c | 12 +++++++++---
drivers/video/fbdev/sh_mobile_lcdcfb.c | 6 +++++-
drivers/video/fbdev/smscufx.c | 9 ++++++---
drivers/video/fbdev/ssd1307fb.c | 6 +++++-
drivers/video/fbdev/udlfb.c | 9 ++++++---
drivers/video/fbdev/xen-fbfront.c | 7 ++++++-
6 files changed, 37 insertions(+), 12 deletions(-)
---
base-commit: 6812ce4e4379ffc99c52401ec28f0d7ffbc36206
change-id: 20260926-fix-fbdefio-error-handling-ab135b0193cb
Best regards,
--
Lorenzo Stoakes (ARM) <ljs@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] fbdev: ssd1307fb: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
@ 2026-09-26 13:16 ` Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 2/6] fbdev: xen-fbfront: " Lorenzo Stoakes (ARM)
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:16 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently ssd1307fb_probe() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due
to an allocation failure) info->fbdefio_state is left NULL.
When the file is subsequently opened, fb_open() will dereference a NULL
pointer (calling fb_deferred_io_open()).
Fix this by checking for the error.
Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/video/fbdev/ssd1307fb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 4d185c754284..8fd96c37ee1a 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -767,7 +767,11 @@ static int ssd1307fb_probe(struct i2c_client *client)
info->fix.smem_start = __pa(vmem);
info->fix.smem_len = vmem_size;
- fb_deferred_io_init(info);
+ ret = fb_deferred_io_init(info);
+ if (ret) {
+ dev_err(dev, "failed to init fb deferred io: %d\n", ret);
+ goto fb_defio_error;
+ }
i2c_set_clientdata(client, info);
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/6] fbdev: xen-fbfront: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
2026-09-26 13:16 ` [PATCH 1/6] fbdev: ssd1307fb: check for fb_deferred_io_init() error Lorenzo Stoakes (ARM)
@ 2026-09-26 13:17 ` Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 3/6] HID: picoLCD: " Lorenzo Stoakes (ARM)
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:17 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently xenfb_probe() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due
to an allocation failure) info->fbdefio_state is left NULL.
When the file is subsequently opened, fb_open() will dereference a NULL
pointer (calling fb_deferred_io_open()).
Fix this by checking for the error.
Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/video/fbdev/xen-fbfront.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c
index 4385976277ac..7ef909d4242d 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -443,7 +443,11 @@ static int xenfb_probe(struct xenbus_device *dev,
}
fb_info->fbdefio = &xenfb_defio;
- fb_deferred_io_init(fb_info);
+ ret = fb_deferred_io_init(fb_info);
+ if (ret < 0) {
+ xenbus_dev_fatal(dev, ret, "fb_deferred_io_init");
+ goto error_cmap;
+ }
xenfb_init_shared_page(info, fb_info);
@@ -465,6 +469,7 @@ static int xenfb_probe(struct xenbus_device *dev,
error_fb:
fb_deferred_io_cleanup(fb_info);
+error_cmap:
fb_dealloc_cmap(&fb_info->cmap);
framebuffer_release(fb_info);
error_nomem:
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/6] HID: picoLCD: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
2026-09-26 13:16 ` [PATCH 1/6] fbdev: ssd1307fb: check for fb_deferred_io_init() error Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 2/6] fbdev: xen-fbfront: " Lorenzo Stoakes (ARM)
@ 2026-09-26 13:17 ` Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 4/6] fbdev: udlfb: " Lorenzo Stoakes (ARM)
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:17 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently picolcd_init_framebuffer() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due
to an allocation failure) info->fbdefio_state is left NULL.
When the file is subsequently opened, fb_open() will dereference a NULL
pointer (calling fb_deferred_io_open()).
Fix this by checking for the error.
Also correct cleanup ordering - defio is initialised after the sysfs file,
so cleanup defio first.
Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/hid/hid-picolcd_fb.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c
index 8c28e982e09d..a016dd9ca847 100644
--- a/drivers/hid/hid-picolcd_fb.c
+++ b/drivers/hid/hid-picolcd_fb.c
@@ -531,17 +531,23 @@ int picolcd_init_framebuffer(struct picolcd_data *data)
goto err_cleanup;
}
- fb_deferred_io_init(info);
+ error = fb_deferred_io_init(info);
+ if (error) {
+ dev_err(dev, "failed to initialize deferred I/O\n");
+ goto err_sysfs;
+ }
+
error = register_framebuffer(info);
if (error) {
dev_err(dev, "failed to register framebuffer\n");
- goto err_sysfs;
+ goto err_defio;
}
return 0;
+err_defio:
+ fb_deferred_io_cleanup(info);
err_sysfs:
device_remove_file(dev, &dev_attr_fb_update_rate);
- fb_deferred_io_cleanup(info);
err_cleanup:
data->fb_info = NULL;
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/6] fbdev: udlfb: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
` (2 preceding siblings ...)
2026-09-26 13:17 ` [PATCH 3/6] HID: picoLCD: " Lorenzo Stoakes (ARM)
@ 2026-09-26 13:17 ` Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 5/6] fbdev: smscufx: " Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 6/6] fbdev: sh_mobile_lcdc: " Lorenzo Stoakes (ARM)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:17 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently dlfb_ops_open() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due to
an allocation failure) info->fbdefio_state is left NULL.
fb_open() will then dereference a NULL pointer (calling
fb_deferred_io_open()) as soon as dlfb_ops_open() returns.
Additionally, if the allocation of info->fbdefio itself fails,
dlfb_ops_open() sets info->fbdefio to NULL and invokes
fb_deferred_io_init() regardless, hitting BUG_ON(!fbdefio).
Fix this by only invoking fb_deferred_io_init() if the allocation
succeeded, and checking for the error.
The driver already supports operating without deferred I/O, so in either
case fall back to that by setting info->fbdefio to NULL.
The ignored return value was introduced in commit 56c134f7f1b5 ("fbdev:
Track deferred-I/O pages in pageref struct").
However, the BUG_ON() issue originates from the earlier
commit 5bea1fbf9423 ("staging: udlfb: fix incorrect fb_defio
implementation for multiple framebuffers"), so target that for the fix.
Fixes: 5bea1fbf9423 ("staging: udlfb: fix incorrect fb_defio implementation for multiple framebuffers")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/video/fbdev/udlfb.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index e78d6f95c9c5..5fbad9355e57 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -947,10 +947,13 @@ static int dlfb_ops_open(struct fb_info *info, int user)
fbdefio->delay = DL_DEFIO_WRITE_DELAY;
fbdefio->sort_pagereflist = true;
fbdefio->deferred_io = dlfb_dpy_deferred_io;
- }
- info->fbdefio = fbdefio;
- fb_deferred_io_init(info);
+ info->fbdefio = fbdefio;
+ if (fb_deferred_io_init(info)) {
+ kfree(fbdefio);
+ info->fbdefio = NULL;
+ }
+ }
}
dev_dbg(info->dev, "open, user=%d fb_info=%p count=%d\n",
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/6] fbdev: smscufx: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
` (3 preceding siblings ...)
2026-09-26 13:17 ` [PATCH 4/6] fbdev: udlfb: " Lorenzo Stoakes (ARM)
@ 2026-09-26 13:17 ` Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 6/6] fbdev: sh_mobile_lcdc: " Lorenzo Stoakes (ARM)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:17 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently ufx_ops_open() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due to
an allocation failure) info->fbdefio_state is left NULL.
fb_open() will then dereference a NULL pointer (calling
fb_deferred_io_open()) as soon as ufx_ops_open() returns.
Additionally, if the allocation of info->fbdefio itself fails,
ufx_ops_open() sets info->fbdefio to NULL and invokes
fb_deferred_io_init() regardless, hitting BUG_ON(!fbdefio).
Fix this by only invoking fb_deferred_io_init() if the allocation
succeeded, and checking for the error.
The driver already supports operating without deferred I/O, so in either
case fall back to that by setting info->fbdefio to NULL.
The ignored return value was introduced in commit 56c134f7f1b5 ("fbdev:
Track deferred-I/O pages in pageref struct").
However, the BUG_ON() issue originates from the earlier
commit 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display
adapters"), so target that for the fix.
Fixes: 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/video/fbdev/smscufx.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 5704f60e1741..34d8abd5b354 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1041,10 +1041,13 @@ static int ufx_ops_open(struct fb_info *info, int user)
if (fbdefio) {
fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
fbdefio->deferred_io = ufx_dpy_deferred_io;
- }
- info->fbdefio = fbdefio;
- fb_deferred_io_init(info);
+ info->fbdefio = fbdefio;
+ if (fb_deferred_io_init(info)) {
+ kfree(fbdefio);
+ info->fbdefio = NULL;
+ }
+ }
}
pr_debug("open /dev/fb%d user=%d fb_info=%p count=%d",
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/6] fbdev: sh_mobile_lcdc: check for fb_deferred_io_init() error
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
` (4 preceding siblings ...)
2026-09-26 13:17 ` [PATCH 5/6] fbdev: smscufx: " Lorenzo Stoakes (ARM)
@ 2026-09-26 13:17 ` Lorenzo Stoakes (ARM)
5 siblings, 0 replies; 7+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-09-26 13:17 UTC (permalink / raw)
To: Helge Deller, Javier Martinez Canillas, Thomas Zimmermann,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Bernie Thompson, Greg Kroah-Hartman, Steve Glendinning,
Florian Tobias Schandinat
Cc: linux-fbdev, dri-devel, linux-kernel, linux-input,
Steve Glendinning, Lorenzo Stoakes (ARM),
stable
fb_deferred_io_init() allocates deferred I/O state, populating
info->fbdefio_state, or leaving it NULL if an error occurs.
Currently sh_mobile_lcdc_start() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due
to an allocation failure) info->fbdefio_state is left NULL.
When the file is subsequently opened, fb_open() will dereference a NULL
pointer (calling fb_deferred_io_open()).
Fix this by checking for the error.
Also clear info->fbdefio in that case, so that sh_mobile_lcdc_stop() does
not attempt to clean up deferred I/O state that was never initialised.
Fixes: 56c134f7f1b5 ("fbdev: Track deferred-I/O pages in pageref struct")
Cc: <stable@vger.kernel.org>
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
drivers/video/fbdev/sh_mobile_lcdcfb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index e8324b01700f..1409a5cc736b 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -1042,7 +1042,11 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
ch->defio.deferred_io = sh_mobile_lcdc_deferred_io;
ch->defio.delay = msecs_to_jiffies(tmp);
ch->info->fbdefio = &ch->defio;
- fb_deferred_io_init(ch->info);
+ ret = fb_deferred_io_init(ch->info);
+ if (ret) {
+ ch->info->fbdefio = NULL;
+ return ret;
+ }
}
sh_mobile_lcdc_display_on(ch);
--
2.55.0
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-09-26 13:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-26 13:16 [PATCH 0/6] fbdev: fixup callers which ignore errors from fb_deferred_io_init() Lorenzo Stoakes (ARM)
2026-09-26 13:16 ` [PATCH 1/6] fbdev: ssd1307fb: check for fb_deferred_io_init() error Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 2/6] fbdev: xen-fbfront: " Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 3/6] HID: picoLCD: " Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 4/6] fbdev: udlfb: " Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 5/6] fbdev: smscufx: " Lorenzo Stoakes (ARM)
2026-09-26 13:17 ` [PATCH 6/6] fbdev: sh_mobile_lcdc: " Lorenzo Stoakes (ARM)
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®