summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev/cobalt_lcdfb.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2023-04-28 15:24:50 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2023-05-08 16:28:34 +0300
commit3f8974f68f408f4983443b745a3cf95b06112469 (patch)
tree7bf2c45c6d071b3d865efaa6135cb5d70e24069d /drivers/video/fbdev/cobalt_lcdfb.c
parent453bd91302f16ddb8a2f5eb3df9fda3206dbacef (diff)
downloadlinux-3f8974f68f408f4983443b745a3cf95b06112469.tar.xz
fbdev: Validate info->screen_{base, buffer} in fb_ops implementations
Push the test for info->screen_base from fb_read() and fb_write() into the implementations of struct fb_ops.{fb_read,fb_write}. In cases where the driver operates on info->screen_buffer, test this field instead. While bothi fields, screen_base and screen_buffer, are stored in the same location, they refer to different address spaces. For correctness, we want to test each field in exactly the code that uses it. v2: * also test screen_base in pvr2fb (Geert) * also test screen_buffer in ivtvfb, arcfb, broadsheetfb, hecubafb, metronomefb and ssd1307fb (Geert) * give a rational for the change (Geert) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Tested-by: Sui Jingfeng <suijingfeng@loongson.cn> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Acked-by: Helge Deller <deller@gmx.de> Link: https://patchwork.freedesktop.org/patch/msgid/20230428122452.4856-18-tzimmermann@suse.de
Diffstat (limited to 'drivers/video/fbdev/cobalt_lcdfb.c')
-rw-r--r--drivers/video/fbdev/cobalt_lcdfb.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 5f8b6324d2e8..26dbd1c78195 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -129,6 +129,9 @@ static ssize_t cobalt_lcdfb_read(struct fb_info *info, char __user *buf,
unsigned long pos;
int len, retval = 0;
+ if (!info->screen_base)
+ return -ENODEV;
+
pos = *ppos;
if (pos >= LCD_CHARS_MAX || count == 0)
return 0;
@@ -175,6 +178,9 @@ static ssize_t cobalt_lcdfb_write(struct fb_info *info, const char __user *buf,
unsigned long pos;
int len, retval = 0;
+ if (!info->screen_base)
+ return -ENODEV;
+
pos = *ppos;
if (pos >= LCD_CHARS_MAX || count == 0)
return 0;