From: Thomas Zimmermann <tzimmermann@suse.de>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, daniel@ffwll.ch, javierm@redhat.com,
deller@gmx.de, geert@linux-m68k.org, sudipm.mukherjee@gmail.com,
teddy.wang@siliconmotion.com
Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 4/6] fbdev: Validate info->screen_{base,buffer} in fb_ops implementations
Date: Tue, 25 Apr 2023 16:28:44 +0200 [thread overview]
Message-ID: <20230425142846.730-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20230425142846.730-1-tzimmermann@suse.de>
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/fbdev/cobalt_lcdfb.c | 6 ++++++
drivers/video/fbdev/core/fb_sys_fops.c | 6 ++++++
drivers/video/fbdev/core/fbmem.c | 10 ++++++++--
drivers/video/fbdev/sm712fb.c | 4 ++--
4 files changed, 22 insertions(+), 4 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;
diff --git a/drivers/video/fbdev/core/fb_sys_fops.c b/drivers/video/fbdev/core/fb_sys_fops.c
index 7dee5d3c7fb1..0cb0989abda6 100644
--- a/drivers/video/fbdev/core/fb_sys_fops.c
+++ b/drivers/video/fbdev/core/fb_sys_fops.c
@@ -22,6 +22,9 @@ ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,
unsigned long total_size, c;
ssize_t ret;
+ if (!info->screen_buffer)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
@@ -61,6 +64,9 @@ ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
unsigned long total_size, c;
size_t ret;
+ if (!info->screen_buffer)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index abc92d79a295..b993bb97058f 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -768,7 +768,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
int c, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || ! info->screen_base)
+ if (!info)
return -ENODEV;
if (info->state != FBINFO_STATE_RUNNING)
@@ -777,6 +777,9 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_read)
return info->fbops->fb_read(info, buf, count, ppos);
+ if (!info->screen_base)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
@@ -833,7 +836,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
int c, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info)
return -ENODEV;
if (info->state != FBINFO_STATE_RUNNING)
@@ -842,6 +845,9 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_write)
return info->fbops->fb_write(info, buf, count, ppos);
+ if (!info->screen_base)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
index 6f852cd756c5..b7ad3c644e13 100644
--- a/drivers/video/fbdev/sm712fb.c
+++ b/drivers/video/fbdev/sm712fb.c
@@ -1028,7 +1028,7 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
int c, i, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info->screen_base)
return -ENODEV;
total_size = info->screen_size;
@@ -1091,7 +1091,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
int c, i, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info->screen_base)
return -ENODEV;
total_size = info->screen_size;
--
2.40.0
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Zimmermann <tzimmermann@suse.de>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
airlied@gmail.com, daniel@ffwll.ch, javierm@redhat.com,
deller@gmx.de, geert@linux-m68k.org, sudipm.mukherjee@gmail.com,
teddy.wang@siliconmotion.com
Cc: linux-fbdev@vger.kernel.org,
Thomas Zimmermann <tzimmermann@suse.de>,
dri-devel@lists.freedesktop.org
Subject: [PATCH 4/6] fbdev: Validate info->screen_{base, buffer} in fb_ops implementations
Date: Tue, 25 Apr 2023 16:28:44 +0200 [thread overview]
Message-ID: <20230425142846.730-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20230425142846.730-1-tzimmermann@suse.de>
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.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/fbdev/cobalt_lcdfb.c | 6 ++++++
drivers/video/fbdev/core/fb_sys_fops.c | 6 ++++++
drivers/video/fbdev/core/fbmem.c | 10 ++++++++--
drivers/video/fbdev/sm712fb.c | 4 ++--
4 files changed, 22 insertions(+), 4 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;
diff --git a/drivers/video/fbdev/core/fb_sys_fops.c b/drivers/video/fbdev/core/fb_sys_fops.c
index 7dee5d3c7fb1..0cb0989abda6 100644
--- a/drivers/video/fbdev/core/fb_sys_fops.c
+++ b/drivers/video/fbdev/core/fb_sys_fops.c
@@ -22,6 +22,9 @@ ssize_t fb_sys_read(struct fb_info *info, char __user *buf, size_t count,
unsigned long total_size, c;
ssize_t ret;
+ if (!info->screen_buffer)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
@@ -61,6 +64,9 @@ ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
unsigned long total_size, c;
size_t ret;
+ if (!info->screen_buffer)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index abc92d79a295..b993bb97058f 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -768,7 +768,7 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
int c, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || ! info->screen_base)
+ if (!info)
return -ENODEV;
if (info->state != FBINFO_STATE_RUNNING)
@@ -777,6 +777,9 @@ fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_read)
return info->fbops->fb_read(info, buf, count, ppos);
+ if (!info->screen_base)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
@@ -833,7 +836,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
int c, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info)
return -ENODEV;
if (info->state != FBINFO_STATE_RUNNING)
@@ -842,6 +845,9 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
if (info->fbops->fb_write)
return info->fbops->fb_write(info, buf, count, ppos);
+ if (!info->screen_base)
+ return -ENODEV;
+
total_size = info->screen_size;
if (total_size == 0)
diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
index 6f852cd756c5..b7ad3c644e13 100644
--- a/drivers/video/fbdev/sm712fb.c
+++ b/drivers/video/fbdev/sm712fb.c
@@ -1028,7 +1028,7 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
int c, i, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info->screen_base)
return -ENODEV;
total_size = info->screen_size;
@@ -1091,7 +1091,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
int c, i, cnt = 0, err = 0;
unsigned long total_size;
- if (!info || !info->screen_base)
+ if (!info->screen_base)
return -ENODEV;
total_size = info->screen_size;
--
2.40.0
next prev parent reply other threads:[~2023-04-25 14:28 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-25 14:28 [PATCH 0/6] drm,fbdev: Use fbdev's I/O helpers Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 14:28 ` [PATCH 1/6] fbdev: Return number of bytes read or written Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 16:15 ` Javier Martinez Canillas
2023-04-25 16:15 ` Javier Martinez Canillas
2023-04-26 9:43 ` [1/6] " Sui Jingfeng
2023-04-26 14:41 ` [PATCH 1/6] " Geert Uytterhoeven
2023-04-26 14:41 ` Geert Uytterhoeven
2023-04-26 15:01 ` Thomas Zimmermann
2023-04-26 15:01 ` Thomas Zimmermann
2023-04-25 14:28 ` [PATCH 2/6] fbdev: Use screen_buffer in fb_sys_{read,write}() Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 16:35 ` Javier Martinez Canillas
2023-04-25 16:35 ` Javier Martinez Canillas
2023-04-26 14:14 ` Thomas Zimmermann
2023-04-26 14:43 ` Geert Uytterhoeven
2023-04-26 14:43 ` Geert Uytterhoeven
2023-04-26 9:47 ` [2/6] " Sui Jingfeng
2023-04-25 14:28 ` [PATCH 3/6] fbdev: Don't re-validate info->state in fb_ops implementations Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 16:38 ` Javier Martinez Canillas
2023-04-25 16:38 ` Javier Martinez Canillas
2023-04-26 9:49 ` [3/6] " Sui Jingfeng
2023-04-26 14:49 ` [PATCH 3/6] " Geert Uytterhoeven
2023-04-26 14:49 ` Geert Uytterhoeven
2023-04-26 15:07 ` Thomas Zimmermann
2023-04-26 15:07 ` Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann [this message]
2023-04-25 14:28 ` [PATCH 4/6] fbdev: Validate info->screen_{base, buffer} " Thomas Zimmermann
2023-04-25 16:39 ` [PATCH 4/6] fbdev: Validate info->screen_{base,buffer} " Javier Martinez Canillas
2023-04-25 16:39 ` Javier Martinez Canillas
2023-04-26 10:24 ` [4/6] fbdev: Validate info->screen_{base, buffer} " Sui Jingfeng
2023-04-26 14:56 ` [PATCH 4/6] fbdev: Validate info->screen_{base,buffer} " Geert Uytterhoeven
2023-04-26 14:56 ` [PATCH 4/6] fbdev: Validate info->screen_{base, buffer} " Geert Uytterhoeven
2023-04-27 13:54 ` [PATCH 4/6] fbdev: Validate info->screen_{base,buffer} " Thomas Zimmermann
2023-04-27 13:54 ` [PATCH 4/6] fbdev: Validate info->screen_{base, buffer} " Thomas Zimmermann
2023-04-25 14:28 ` [PATCH 5/6] fbdev: Move CFB read and write code into helper functions Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 16:47 ` Javier Martinez Canillas
2023-04-25 16:47 ` Javier Martinez Canillas
2023-04-26 5:16 ` kernel test robot
2023-04-26 5:16 ` kernel test robot
2023-04-26 14:24 ` Thomas Zimmermann
2023-04-26 14:24 ` Thomas Zimmermann
2023-04-26 6:07 ` kernel test robot
2023-04-26 6:07 ` kernel test robot
2023-04-26 6:47 ` kernel test robot
2023-04-26 6:47 ` kernel test robot
2023-04-26 10:25 ` [5/6] " Sui Jingfeng
2023-04-26 15:01 ` [PATCH 5/6] " Geert Uytterhoeven
2023-04-26 15:01 ` Geert Uytterhoeven
2023-04-26 15:06 ` Thomas Zimmermann
2023-04-26 15:06 ` Thomas Zimmermann
2023-04-26 15:21 ` Geert Uytterhoeven
2023-04-26 15:21 ` Geert Uytterhoeven
2023-04-28 11:20 ` Thomas Zimmermann
2023-04-28 11:20 ` Thomas Zimmermann
2023-04-28 12:20 ` Geert Uytterhoeven
2023-04-28 12:20 ` Geert Uytterhoeven
2023-04-25 14:28 ` [PATCH 6/6] drm/fb-helper: Use fb_{cfb,sys}_{read, write}() Thomas Zimmermann
2023-04-25 14:28 ` Thomas Zimmermann
2023-04-25 16:50 ` Javier Martinez Canillas
2023-04-25 16:50 ` Javier Martinez Canillas
2023-04-26 10:26 ` [6/6] " Sui Jingfeng
2023-04-26 15:15 ` [PATCH 6/6] " Geert Uytterhoeven
2023-04-26 15:15 ` Geert Uytterhoeven
2023-04-28 11:25 ` Thomas Zimmermann
2023-04-28 11:25 ` Thomas Zimmermann
2023-04-25 19:17 ` [PATCH 0/6] drm,fbdev: Use fbdev's I/O helpers Helge Deller
2023-04-25 19:17 ` Helge Deller
2023-04-26 10:33 ` Sui Jingfeng
2023-04-26 11:22 ` Thomas Zimmermann
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=20230425142846.730-5-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=javierm@redhat.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sudipm.mukherjee@gmail.com \
--cc=teddy.wang@siliconmotion.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.