* [PATCH] drm: vkms: check status of alloc_ordered_workqueue
@ 2019-03-09 4:36 Kangjie Lu
2019-03-23 2:32 ` Kangjie Lu
2019-03-23 10:05 ` Mukesh Ojha
0 siblings, 2 replies; 8+ messages in thread
From: Kangjie Lu @ 2019-03-09 4:36 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
alloc_ordered_workqueue may fail and return NULL.
The fix returns ENOMEM when it fails to avoid potential NULL
pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 8a9aeb0a9ea8..bb66dbcd5e3f 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -219,6 +219,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
spin_lock_init(&vkms_out->state_lock);
vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
+ if (!vkms_out->crc_workq)
+ return -ENOMEM;
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] drm: vkms: check status of alloc_ordered_workqueue
2019-03-09 4:36 [PATCH] drm: vkms: check status of alloc_ordered_workqueue Kangjie Lu
@ 2019-03-23 2:32 ` Kangjie Lu
2019-03-25 8:34 ` Daniel Vetter
2019-03-23 10:05 ` Mukesh Ojha
1 sibling, 1 reply; 8+ messages in thread
From: Kangjie Lu @ 2019-03-23 2:32 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
> On Mar 8, 2019, at 10:36 PM, Kangjie Lu <kjlu@umn.edu> wrote:
>
> alloc_ordered_workqueue may fail and return NULL.
> The fix returns ENOMEM when it fails to avoid potential NULL
> pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8a9aeb0a9ea8..bb66dbcd5e3f 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -219,6 +219,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> spin_lock_init(&vkms_out->state_lock);
>
> vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> + if (!vkms_out->crc_workq)
> + return -ENOMEM;
Is this a reasonable patch?
>
> return ret;
> }
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm: vkms: check status of alloc_ordered_workqueue
2019-03-09 4:36 [PATCH] drm: vkms: check status of alloc_ordered_workqueue Kangjie Lu
2019-03-23 2:32 ` Kangjie Lu
@ 2019-03-23 10:05 ` Mukesh Ojha
2019-03-23 21:42 ` [PATCH v2] " Kangjie Lu
1 sibling, 1 reply; 8+ messages in thread
From: Mukesh Ojha @ 2019-03-23 10:05 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
On 3/9/2019 10:06 AM, Kangjie Lu wrote:
> alloc_ordered_workqueue may fail and return NULL.
> The fix returns ENOMEM when it fails to avoid potential NULL
> pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8a9aeb0a9ea8..bb66dbcd5e3f 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -219,6 +219,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> spin_lock_init(&vkms_out->state_lock);
>
> vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> + if (!vkms_out->crc_workq)
> + return -ENOMEM;
>
> return ret;
> }
Check the clean up path more carefully, you have undo which you have
done successfully in drm_crtc_init_with_planes.
Thanks,
Mukesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] drm: vkms: check status of alloc_ordered_workqueue
2019-03-23 10:05 ` Mukesh Ojha
@ 2019-03-23 21:42 ` Kangjie Lu
2019-03-25 8:31 ` Daniel Vetter
0 siblings, 1 reply; 8+ messages in thread
From: Kangjie Lu @ 2019-03-23 21:42 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
alloc_ordered_workqueue may fail and return NULL.
The fix cleans up drm plans and returns ENOMEM when it fails to
avoid potential NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
V2: clean up resources
---
drivers/gpu/drm/vkms/vkms_crtc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
index 8a9aeb0a9ea8..018b52dd953a 100644
--- a/drivers/gpu/drm/vkms/vkms_crtc.c
+++ b/drivers/gpu/drm/vkms/vkms_crtc.c
@@ -219,6 +219,17 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
spin_lock_init(&vkms_out->state_lock);
vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
+ if (!vkms_out->crc_workq) {
+ ret = -ENOMEM;
+ goto cleanup;
+ }
+
+ return ret;
+cleanup:
+ if (!IS_ERR_OR_NULL(cursor))
+ drm_plane_cleanup(cursor);
+ if (!IS_ERR(primary))
+ drm_plane_cleanup(primary);
return ret;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] drm: vkms: check status of alloc_ordered_workqueue
2019-03-23 21:42 ` [PATCH v2] " Kangjie Lu
@ 2019-03-25 8:31 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2019-03-25 8:31 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
On Sat, Mar 23, 2019 at 04:42:16PM -0500, Kangjie Lu wrote:
> alloc_ordered_workqueue may fail and return NULL.
> The fix cleans up drm plans and returns ENOMEM when it fails to
> avoid potential NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> V2: clean up resources
> ---
> drivers/gpu/drm/vkms/vkms_crtc.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8a9aeb0a9ea8..018b52dd953a 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -219,6 +219,17 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> spin_lock_init(&vkms_out->state_lock);
>
> vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> + if (!vkms_out->crc_workq) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + return ret;
>
> +cleanup:
Style nit for the future, for clarity I'd label this err:, since this path
is only taken for failures, and not to do cleanup for all cases.
Aside from that, I think your v1 was correct, vkms_crtc_init only sets up
the crtc, it doesn't allocate the cursor/planes. That's done from
vkms_output_init, which already has the cleanup code to handle this case.
-Daniel
> + if (!IS_ERR_OR_NULL(cursor))
> + drm_plane_cleanup(cursor);
> + if (!IS_ERR(primary))
> + drm_plane_cleanup(primary);
> return ret;
> }
> --
> 2.17.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] drm: vkms: check status of alloc_ordered_workqueue
@ 2019-03-25 8:31 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2019-03-25 8:31 UTC (permalink / raw)
To: Kangjie Lu
Cc: Haneen Mohammed, Rodrigo Siqueira, David Airlie, linux-kernel,
dri-devel, pakki001
On Sat, Mar 23, 2019 at 04:42:16PM -0500, Kangjie Lu wrote:
> alloc_ordered_workqueue may fail and return NULL.
> The fix cleans up drm plans and returns ENOMEM when it fails to
> avoid potential NULL pointer dereference.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> V2: clean up resources
> ---
> drivers/gpu/drm/vkms/vkms_crtc.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> index 8a9aeb0a9ea8..018b52dd953a 100644
> --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> @@ -219,6 +219,17 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> spin_lock_init(&vkms_out->state_lock);
>
> vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> + if (!vkms_out->crc_workq) {
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + return ret;
>
> +cleanup:
Style nit for the future, for clarity I'd label this err:, since this path
is only taken for failures, and not to do cleanup for all cases.
Aside from that, I think your v1 was correct, vkms_crtc_init only sets up
the crtc, it doesn't allocate the cursor/planes. That's done from
vkms_output_init, which already has the cleanup code to handle this case.
-Daniel
> + if (!IS_ERR_OR_NULL(cursor))
> + drm_plane_cleanup(cursor);
> + if (!IS_ERR(primary))
> + drm_plane_cleanup(primary);
> return ret;
> }
> --
> 2.17.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm: vkms: check status of alloc_ordered_workqueue
2019-03-23 2:32 ` Kangjie Lu
@ 2019-03-25 8:34 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2019-03-25 8:34 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Rodrigo Siqueira, Haneen Mohammed, Daniel Vetter,
David Airlie, dri-devel, linux-kernel
On Fri, Mar 22, 2019 at 09:32:07PM -0500, Kangjie Lu wrote:
>
>
> > On Mar 8, 2019, at 10:36 PM, Kangjie Lu <kjlu@umn.edu> wrote:
> >
> > alloc_ordered_workqueue may fail and return NULL.
> > The fix returns ENOMEM when it fails to avoid potential NULL
> > pointer dereference.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> > index 8a9aeb0a9ea8..bb66dbcd5e3f 100644
> > --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> > @@ -219,6 +219,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> > spin_lock_init(&vkms_out->state_lock);
> >
> > vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> > + if (!vkms_out->crc_workq)
> > + return -ENOMEM;
>
> Is this a reasonable patch?
lgtm, applied and thanks for your patch.
-Daniel
>
> >
> > return ret;
> > }
> > --
> > 2.17.1
> >
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm: vkms: check status of alloc_ordered_workqueue
@ 2019-03-25 8:34 ` Daniel Vetter
0 siblings, 0 replies; 8+ messages in thread
From: Daniel Vetter @ 2019-03-25 8:34 UTC (permalink / raw)
To: Kangjie Lu
Cc: Haneen Mohammed, Rodrigo Siqueira, David Airlie, linux-kernel,
dri-devel, pakki001
On Fri, Mar 22, 2019 at 09:32:07PM -0500, Kangjie Lu wrote:
>
>
> > On Mar 8, 2019, at 10:36 PM, Kangjie Lu <kjlu@umn.edu> wrote:
> >
> > alloc_ordered_workqueue may fail and return NULL.
> > The fix returns ENOMEM when it fails to avoid potential NULL
> > pointer dereference.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > drivers/gpu/drm/vkms/vkms_crtc.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/vkms/vkms_crtc.c b/drivers/gpu/drm/vkms/vkms_crtc.c
> > index 8a9aeb0a9ea8..bb66dbcd5e3f 100644
> > --- a/drivers/gpu/drm/vkms/vkms_crtc.c
> > +++ b/drivers/gpu/drm/vkms/vkms_crtc.c
> > @@ -219,6 +219,8 @@ int vkms_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
> > spin_lock_init(&vkms_out->state_lock);
> >
> > vkms_out->crc_workq = alloc_ordered_workqueue("vkms_crc_workq", 0);
> > + if (!vkms_out->crc_workq)
> > + return -ENOMEM;
>
> Is this a reasonable patch?
lgtm, applied and thanks for your patch.
-Daniel
>
> >
> > return ret;
> > }
> > --
> > 2.17.1
> >
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-03-25 8:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-09 4:36 [PATCH] drm: vkms: check status of alloc_ordered_workqueue Kangjie Lu
2019-03-23 2:32 ` Kangjie Lu
2019-03-25 8:34 ` Daniel Vetter
2019-03-25 8:34 ` Daniel Vetter
2019-03-23 10:05 ` Mukesh Ojha
2019-03-23 21:42 ` [PATCH v2] " Kangjie Lu
2019-03-25 8:31 ` Daniel Vetter
2019-03-25 8:31 ` Daniel Vetter
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.