mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fbcon: Add check for return value
@ 2025-12-17  9:11 Ваторопин Андрей
  2025-12-30  9:27 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Ваторопин Андрей @ 2025-12-17  9:11 UTC (permalink / raw)
  To: Simona Vetter
  Cc: Ваторопин
	Андрей,
	Helge Deller, Thomas Zimmermann, Ville Syrjälä,
	Sam Ravnborg, Shixiong Ou, Kees Cook, Zsolt Kajtar,
	Andrew Morton, Antonino A. Daplas, linux-fbdev, dri-devel,
	linux-kernel, lvc-project, stable

From: Andrey Vatoropin <a.vatoropin@crpt.ru>

If fbcon_open() fails when called from con2fb_acquire_newinfo() then
info->fbcon_par pointer remains NULL which is later dereferenced.

Add check for return value of the function con2fb_acquire_newinfo() to
avoid it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: d1baa4ffa677 ("fbcon: set_con2fb_map fixes")
Cc: stable@vger.kernel.org
Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
---
 drivers/video/fbdev/core/fbcon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index e7e07eb2142e..7453377f3433 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -1047,7 +1047,8 @@ static void fbcon_init(struct vc_data *vc, bool init)
 		return;
 
 	if (!info->fbcon_par)
-		con2fb_acquire_newinfo(vc, info, vc->vc_num);
+		if (con2fb_acquire_newinfo(vc, info, vc->vc_num))
+			return;
 
 	/* If we are not the first console on this
 	   fb, copy the font from that console */
-- 
2.43.0

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

* Re: [PATCH] fbcon: Add check for return value
  2025-12-17  9:11 [PATCH] fbcon: Add check for return value Ваторопин Андрей
@ 2025-12-30  9:27 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2025-12-30  9:27 UTC (permalink / raw)
  To: Ваторопин
	Андрей
  Cc: linux-fbdev, dri-devel, linux-kernel, lvc-project

On 12/17/25 10:11, ÐаÑоÑопин ÐндÑей wrote:
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
> 
> If fbcon_open() fails when called from con2fb_acquire_newinfo() then
> info->fbcon_par pointer remains NULL which is later dereferenced.
> 
> Add check for return value of the function con2fb_acquire_newinfo() to
> avoid it.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

I was unsure if I should apply this patch since we don't have a real problem.

This is inside the fbcon_init() function, so if con2fb_acquire_newinfo()
ever would have returned NULL, the kernel would have crashed and someone
would have reported it (or will report in the future if it happens).

Nevertheless, for correctness, I was tempted to change the check to a
WARN_ON() or BUG_ON() instead, but again: it never happened, so why
add bloat to the kernel ?

In the end, I've now applied this patch to the linux-fbdev git tree
as-is, just to avoid other people send similar patches based on
verification tool reports...

Thanks!
Helge
  
> Fixes: d1baa4ffa677 ("fbcon: set_con2fb_map fixes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
>   drivers/video/fbdev/core/fbcon.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index e7e07eb2142e..7453377f3433 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -1047,7 +1047,8 @@ static void fbcon_init(struct vc_data *vc, bool init)
>   		return;
>   
>   	if (!info->fbcon_par)
> -		con2fb_acquire_newinfo(vc, info, vc->vc_num);
> +		if (con2fb_acquire_newinfo(vc, info, vc->vc_num))
> +			return;
>   
>   	/* If we are not the first console on this
>   	   fb, copy the font from that console */


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

end of thread, other threads:[~2025-12-30  9:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-17  9:11 [PATCH] fbcon: Add check for return value Ваторопин Андрей
2025-12-30  9:27 ` Helge Deller

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®