mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Helge Deller" <deller@gmx.de>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Bruno Prémont" <bonbons@linux-vserver.org>,
	"Jiri Kosina" <jikos@kernel.org>,
	"Benjamin Tissoires" <bentiss@kernel.org>,
	"Bernie Thompson" <bernie@plugable.com>,
	"Greg Kroah-Hartman" <gregkh@suse.de>,
	"Steve Glendinning" <steve.glendinning@shawell.net>,
	"Florian Tobias Schandinat" <FlorianSchandinat@gmx.de>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	 linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	 Steve Glendinning <steve.glendinning@smsc.com>,
	 "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	stable@vger.kernel.org
Subject: [PATCH 4/6] fbdev: udlfb: check for fb_deferred_io_init() error
Date: Sat, 26 Sep 2026 14:17:02 +0100	[thread overview]
Message-ID: <20260926-fix-fbdefio-error-handling-v1-4-a94810b6e263@kernel.org> (raw)
In-Reply-To: <20260926-fix-fbdefio-error-handling-v1-0-a94810b6e263@kernel.org>

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


  parent reply	other threads:[~2026-09-26 13:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Lorenzo Stoakes (ARM) [this message]
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)

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=20260926-fix-fbdefio-error-handling-v1-4-a94810b6e263@kernel.org \
    --to=ljs@kernel.org \
    --cc=FlorianSchandinat@gmx.de \
    --cc=bentiss@kernel.org \
    --cc=bernie@plugable.com \
    --cc=bonbons@linux-vserver.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@suse.de \
    --cc=javierm@redhat.com \
    --cc=jikos@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steve.glendinning@shawell.net \
    --cc=steve.glendinning@smsc.com \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®