[PATCH 1/2] fbdev: udlfb: drop stale shadow buffer when the framebuffer grows
From: YuanZhe Liu
Date: Fri Dec 04 2026 - 04:05:28 EST
dlfb_realloc_framebuffer() grows the virtual framebuffer when a larger
video mode is set. The shadow buffer that mirrors the data sent to the
device is only reallocated when shadowing is enabled and the allocation
succeeds. If shadowing is disabled at runtime or the allocation fails,
the driver logs a message but keeps the previous, smaller shadow buffer.
dlfb_render_hline() then compares lines of the new framebuffer against
the old shadow buffer at offsets derived from the new geometry, reading
beyond the end of the smaller allocation.
Drop the old shadow buffer when a new one cannot be created, so that
damage rendering falls back to sending the full line as intended.
Fixes: 7433914efd58 ("udlfb: allow reallocating the framebuffer")
Cc: stable@xxxxxxxxxxxxxxx
Co-developed-by: Bin Yu <byu@xxxxxxxxxxxxx>
Signed-off-by: Bin Yu <byu@xxxxxxxxxxxxx>
Co-developed-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: Cheng Wen <wencheng@xxxxxxxxxxxxx>
Signed-off-by: YuanZhe Liu <25031212351@xxxxxxxxxxxxxxxxx>
---
drivers/video/fbdev/udlfb.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c
index 8b7b4bdac4fb..917bcef4bb69 100644
--- a/drivers/video/fbdev/udlfb.c
+++ b/drivers/video/fbdev/udlfb.c
@@ -1248,10 +1248,18 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dlfb, struct fb_info *info
*/
if (shadow)
new_back = vzalloc(new_len);
- if (!new_back)
+ if (!new_back) {
dev_info(info->dev,
"No shadow/backing buffer allocated\n");
- else {
+ /*
+ * The old shadow buffer is smaller than the new
+ * framebuffer and can no longer be used for comparing.
+ */
+ if (dlfb->backing_buffer) {
+ dlfb_deferred_vfree(dlfb, dlfb->backing_buffer);
+ dlfb->backing_buffer = NULL;
+ }
+ } else {
dlfb_deferred_vfree(dlfb, dlfb->backing_buffer);
dlfb->backing_buffer = new_back;
}
--
2.34.1