linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbdev: hyperv_fb: fix uninitialized local variable use
@ 2023-11-08 14:58 Arnd Bergmann
  2023-11-08 15:38 ` Helge Deller
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2023-11-08 14:58 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Helge Deller, Greg Kroah-Hartman, Javier Martinez Canillas,
	Arnd Bergmann
  Cc: kernel test robot, Dan Carpenter, Thomas Zimmermann,
	Michael Kelley, Guilherme G. Piccoli, Kirill A. Shutemov,
	Dawei Li, linux-hyperv, linux-fbdev, dri-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When CONFIG_SYSFB is disabled, the hyperv_fb driver can now run into
undefined behavior on a gen2 VM, as indicated by this smatch warning:

drivers/video/fbdev/hyperv_fb.c:1077 hvfb_getmem() error: uninitialized symbol 'base'.
drivers/video/fbdev/hyperv_fb.c:1077 hvfb_getmem() error: uninitialized symbol 'size'.

Since there is no way to know the actual framebuffer in this configuration,
just return an allocation failure here, which should avoid the build
warning and the undefined behavior.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202311070802.YCpvehaz-lkp@intel.com/
Fixes: a07b50d80ab6 ("hyperv: avoid dependency on screen_info")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/video/fbdev/hyperv_fb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
index bf59daf862fc..a80939fe2ee6 100644
--- a/drivers/video/fbdev/hyperv_fb.c
+++ b/drivers/video/fbdev/hyperv_fb.c
@@ -1013,6 +1013,8 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
 	} else if (IS_ENABLED(CONFIG_SYSFB)) {
 		base = screen_info.lfb_base;
 		size = screen_info.lfb_size;
+	} else {
+		goto err1;
 	}
 
 	/*
-- 
2.39.2


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

* Re: [PATCH] fbdev: hyperv_fb: fix uninitialized local variable use
  2023-11-08 14:58 [PATCH] fbdev: hyperv_fb: fix uninitialized local variable use Arnd Bergmann
@ 2023-11-08 15:38 ` Helge Deller
  0 siblings, 0 replies; 2+ messages in thread
From: Helge Deller @ 2023-11-08 15:38 UTC (permalink / raw)
  To: Arnd Bergmann, K. Y. Srinivasan, Haiyang Zhang, Wei Liu,
	Dexuan Cui, Greg Kroah-Hartman, Javier Martinez Canillas,
	Arnd Bergmann
  Cc: kernel test robot, Dan Carpenter, Thomas Zimmermann,
	Michael Kelley, Guilherme G. Piccoli, Kirill A. Shutemov,
	Dawei Li, linux-hyperv, linux-fbdev, dri-devel, linux-kernel

On 11/8/23 15:58, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> When CONFIG_SYSFB is disabled, the hyperv_fb driver can now run into
> undefined behavior on a gen2 VM, as indicated by this smatch warning:
>
> drivers/video/fbdev/hyperv_fb.c:1077 hvfb_getmem() error: uninitialized symbol 'base'.
> drivers/video/fbdev/hyperv_fb.c:1077 hvfb_getmem() error: uninitialized symbol 'size'.
>
> Since there is no way to know the actual framebuffer in this configuration,
> just return an allocation failure here, which should avoid the build
> warning and the undefined behavior.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202311070802.YCpvehaz-lkp@intel.com/
> Fixes: a07b50d80ab6 ("hyperv: avoid dependency on screen_info")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

applied.

Thanks!
Helge


> ---
>   drivers/video/fbdev/hyperv_fb.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
> index bf59daf862fc..a80939fe2ee6 100644
> --- a/drivers/video/fbdev/hyperv_fb.c
> +++ b/drivers/video/fbdev/hyperv_fb.c
> @@ -1013,6 +1013,8 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
>   	} else if (IS_ENABLED(CONFIG_SYSFB)) {
>   		base = screen_info.lfb_base;
>   		size = screen_info.lfb_size;
> +	} else {
> +		goto err1;
>   	}
>
>   	/*


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

end of thread, other threads:[~2023-11-08 15:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-08 14:58 [PATCH] fbdev: hyperv_fb: fix uninitialized local variable use Arnd Bergmann
2023-11-08 15:38 ` Helge Deller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).