Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the return value of 
`drm_sched_entity_init()` is ignored when creating a VM_BIND submitqueue, which 
can lead to a kernel crash if the allocation fails.
--

--- Patch [2]: [PATCH v7 02/17] drm/msm: Rework queuelock ---
commit 1fecfbcd368f21f80f7078762ebd5da9fae4c122
Author: Rob Clark <[email protected]>

drm/msm: Rework queuelock

This commit renames queuelock to ctxlock and transitions it to use cleanup
guards. The change is intended to allow the lock to be reused for other
per-context read/write serialization tasks such as VM creation.

> diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c 
> b/drivers/gpu/drm/msm/msm_submitqueue.c
> index 1a5a77b280163..8b5980d5a6a79 100644
> --- a/drivers/gpu/drm/msm/msm_submitqueue.c
> +++ b/drivers/gpu/drm/msm/msm_submitqueue.c

[ ... ]

> @@ -237,7 +234,7 @@ int msm_submitqueue_create(struct drm_device *drm, struct 
> msm_context *ctx,
>               return ret;
>       }
>  
> -     write_lock(&ctx->queuelock);
> +     guard(rwsem_write)(&ctx->ctxlock);

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a potential bug in
the VM_BIND queue initialization just above this locking change in
msm_submitqueue_create().

Does this code fail to catch allocation errors from drm_sched_entity_init()?

        if (flags & MSM_SUBMITQUEUE_VM_BIND) {
                ...
                drm_sched_entity_init(queue->entity, DRM_SCHED_PRIORITY_KERNEL,
                                      &sched, 1, NULL);
        } else {
                ...
        }

        if (IS_ERR(queue->entity)) {
                ret = PTR_ERR(queue->entity);
                ...

If drm_sched_entity_init() fails, it returns an error but the return value is
silently ignored. The subsequent check for IS_ERR(queue->entity) will evaluate
to false because queue->entity points to a valid inline struct array element
(&queue->_vm_bind_entity[0]).

Could this result in a NULL pointer dereference later on if a job is submitted
to this partially initialized scheduler entity?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=2

Reply via email to