* [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
@ 2023-10-27 9:19 ` Peng Hao
0 siblings, 0 replies; 6+ messages in thread
From: Peng Hao @ 2023-10-27 9:19 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel
Cc: penghao, linux-kernel, dri-devel
Since drm_get_format_info() may return NULL, so a judgement of return
value is needed to add.
Signed-off-by: Peng Hao <penghao@dingdao.com>
---
drivers/gpu/drm/drm_framebuffer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index aff3746dedfb..be7dd1998c04 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
/* now let the driver pick its own format info */
info = drm_get_format_info(dev, r);
+ if (!info) {
+ drm_dbg_kms(dev, "no matched format info\n");
+ return -EFAULT;
+ }
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
--
2.37.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
@ 2023-10-27 9:19 ` Peng Hao
0 siblings, 0 replies; 6+ messages in thread
From: Peng Hao @ 2023-10-27 9:19 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel
Cc: dri-devel, linux-kernel, penghao
Since drm_get_format_info() may return NULL, so a judgement of return
value is needed to add.
Signed-off-by: Peng Hao <penghao@dingdao.com>
---
drivers/gpu/drm/drm_framebuffer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index aff3746dedfb..be7dd1998c04 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
/* now let the driver pick its own format info */
info = drm_get_format_info(dev, r);
+ if (!info) {
+ drm_dbg_kms(dev, "no matched format info\n");
+ return -EFAULT;
+ }
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
--
2.37.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
2023-10-27 9:19 ` Peng Hao
(?)
@ 2023-10-27 12:32 ` Ville Syrjälä
2023-10-30 9:08 ` 彭昊
2023-10-30 9:24 ` 彭昊
-1 siblings, 2 replies; 6+ messages in thread
From: Ville Syrjälä @ 2023-10-27 12:32 UTC (permalink / raw)
To: Peng Hao; +Cc: tzimmermann, linux-kernel, mripard, dri-devel
On Fri, Oct 27, 2023 at 05:19:12PM +0800, Peng Hao wrote:
> Since drm_get_format_info() may return NULL,
Not in this case since we already checked it earlier.
> so a judgement of return
> value is needed to add.
>
> Signed-off-by: Peng Hao <penghao@dingdao.com>
> ---
> drivers/gpu/drm/drm_framebuffer.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> index aff3746dedfb..be7dd1998c04 100644
> --- a/drivers/gpu/drm/drm_framebuffer.c
> +++ b/drivers/gpu/drm/drm_framebuffer.c
> @@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
>
> /* now let the driver pick its own format info */
> info = drm_get_format_info(dev, r);
> + if (!info) {
> + drm_dbg_kms(dev, "no matched format info\n");
> + return -EFAULT;
> + }
>
> for (i = 0; i < info->num_planes; i++) {
> unsigned int width = fb_plane_width(r->width, info, i);
> --
> 2.37.1
--
Ville Syrjälä
Intel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
2023-10-27 12:32 ` Ville Syrjälä
@ 2023-10-30 9:08 ` 彭昊
2023-10-30 9:24 ` 彭昊
1 sibling, 0 replies; 6+ messages in thread
From: 彭昊 @ 2023-10-30 9:08 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: tzimmermann, linux-kernel, mripard, dri-devel
[-- Attachment #1: Type: text/plain, Size: 2322 bytes --]
Hi, Ville & all
Thanks for quick reply!
According to your reply, the *info has been checked info earlier, and I have read the code of framebuffer_check() and related drm_get_format_info() which it calls, but unfortunatelly, I haven't seen judgement(check) for it. What I only found related with check is the sentence below (in *drm_format_info() in drivers/gpu/drm/drm_fourcc.c):
```
info = __drm_format_info(format);
WARN_ON(!info);
```
But to the best of my knowledge, "WARN_ON" only gives a dump_stack(), not discontinue the program going on, so it will indeed go to the below line in framebuffer_check() and raise an error:
```
for (i = 0; i < info->num_planes; i++) {
```
So maybe it will make sense of my commited code.
Looking forward to your reply and guidance.
> From: "Ville Syrjälä"<ville.syrjala@linux.intel.com>
> Date: Fri, Oct 27, 2023, 20:33
> Subject: Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
> To: "Peng Hao"<penghao@dingdao.com>
> Cc: <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>, <tzimmermann@suse.de>, <airlied@gmail.com>, <daniel@ffwll.ch>, <linux-kernel@vger.kernel.org>, <dri-devel@lists.freedesktop.org>
> On Fri, Oct 27, 2023 at 05:19:12PM +0800, Peng Hao wrote:
> > Since drm_get_format_info() may return NULL,
>
> Not in this case since we already checked it earlier.
>
> > so a judgement of return
> > value is needed to add.
> >
> > Signed-off-by: Peng Hao <penghao@dingdao.com>
> > ---
> > drivers/gpu/drm/drm_framebuffer.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> > index aff3746dedfb..be7dd1998c04 100644
> > --- a/drivers/gpu/drm/drm_framebuffer.c
> > +++ b/drivers/gpu/drm/drm_framebuffer.c
> > @@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
> >
> > /* now let the driver pick its own format info */
> > info = drm_get_format_info(dev, r);
> > + if (!info) {
> > + drm_dbg_kms(dev, "no matched format info\n");
> > + return -EFAULT;
> > + }
> >
> > for (i = 0; i < info->num_planes; i++) {
> > unsigned int width = fb_plane_width(r->width, info, i);
> > --
> > 2.37.1
>
> --
> Ville Syrjälä
> Intel
[-- Attachment #2: Type: text/html, Size: 8529 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
2023-10-27 12:32 ` Ville Syrjälä
2023-10-30 9:08 ` 彭昊
@ 2023-10-30 9:24 ` 彭昊
1 sibling, 0 replies; 6+ messages in thread
From: 彭昊 @ 2023-10-30 9:24 UTC (permalink / raw)
To: Ville Syrjälä; +Cc: tzimmermann, linux-kernel, mripard, dri-devel
[-- Attachment #1: Type: text/plain, Size: 2322 bytes --]
Hi, Ville & all
Thanks for quick reply!
According to your reply, the *info has been checked info earlier, and I have read the code of framebuffer_check() and related drm_get_format_info() which it calls, but unfortunatelly, I haven't seen judgement(check) for it. What I only found related with check is the sentence below (in *drm_format_info() in drivers/gpu/drm/drm_fourcc.c):
```
info = __drm_format_info(format);
WARN_ON(!info);
```
But to the best of my knowledge, "WARN_ON" only gives a dump_stack(), not discontinue the program going on, so it will indeed go to the below line in framebuffer_check() and raise an error:
```
for (i = 0; i < info->num_planes; i++) {
```
So maybe it will make sense of my commited code.
Looking forward to your reply and guidance.
> From: "Ville Syrjälä"<ville.syrjala@linux.intel.com>
> Date: Fri, Oct 27, 2023, 20:33
> Subject: Re: [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
> To: "Peng Hao"<penghao@dingdao.com>
> Cc: <maarten.lankhorst@linux.intel.com>, <mripard@kernel.org>, <tzimmermann@suse.de>, <airlied@gmail.com>, <daniel@ffwll.ch>, <linux-kernel@vger.kernel.org>, <dri-devel@lists.freedesktop.org>
> On Fri, Oct 27, 2023 at 05:19:12PM +0800, Peng Hao wrote:
> > Since drm_get_format_info() may return NULL,
>
> Not in this case since we already checked it earlier.
>
> > so a judgement of return
> > value is needed to add.
> >
> > Signed-off-by: Peng Hao <penghao@dingdao.com>
> > ---
> > drivers/gpu/drm/drm_framebuffer.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> > index aff3746dedfb..be7dd1998c04 100644
> > --- a/drivers/gpu/drm/drm_framebuffer.c
> > +++ b/drivers/gpu/drm/drm_framebuffer.c
> > @@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
> >
> > /* now let the driver pick its own format info */
> > info = drm_get_format_info(dev, r);
> > + if (!info) {
> > + drm_dbg_kms(dev, "no matched format info\n");
> > + return -EFAULT;
> > + }
> >
> > for (i = 0; i < info->num_planes; i++) {
> > unsigned int width = fb_plane_width(r->width, info, i);
> > --
> > 2.37.1
>
> --
> Ville Syrjälä
> Intel
[-- Attachment #2: Type: text/html, Size: 8529 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info().
@ 2023-10-30 9:30 彭昊
0 siblings, 0 replies; 6+ messages in thread
From: 彭昊 @ 2023-10-30 9:30 UTC (permalink / raw)
To: maarten.lankhorst, mripard, tzimmermann, airlied, daniel
Cc: 彭昊, linux-kernel, dri-devel
[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]
According to your(Villie) reply, the *info has been checked info earlier, and I have read the code of framebuffer_check() and related drm_get_format_info() which it calls, but unfortunatelly, I haven't seen judgement(check) for it. What I only found related with check is the sentence below (in *drm_format_info() in drivers/gpu/drm/drm_fourcc.c):
```
info = __drm_format_info(format);
WARN_ON(!info);
```
But to the best of my knowledge, "WARN_ON" only gives a dump_stack(), not discontinue the program going on, so it will indeed go to the below line in framebuffer_check() and raise an error:
```
for (i = 0; i < info->num_planes; i++) {
```
So maybe it will make sense of my commited code.
Signed-off-by: Peng Hao <penghao@dingdao.com>
---
drivers/gpu/drm/drm_framebuffer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index aff3746dedfb..be7dd1998c04 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -194,6 +194,10 @@ static int framebuffer_check(struct drm_device *dev,
/* now let the driver pick its own format info */
info = drm_get_format_info(dev, r);
+ if (!info) {
+ drm_dbg_kms(dev, "no matched format info\n");
+ return -EFAULT;
+ }
for (i = 0; i < info->num_planes; i++) {
unsigned int width = fb_plane_width(r->width, info, i);
--
2.37.1
[-- Attachment #2: Type: text/html, Size: 15038 bytes --]
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-10-30 9:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-27 9:19 [PATCH] gpu/drm/drm_framebuffer.c: Add judgement for return value of drm_get_format_info() Peng Hao
2023-10-27 9:19 ` Peng Hao
2023-10-27 12:32 ` Ville Syrjälä
2023-10-30 9:08 ` 彭昊
2023-10-30 9:24 ` 彭昊
-- strict thread matches above, loose matches on Subject: below --
2023-10-30 9:30 彭昊
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.