Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] The fault attribute `wedge_cold_reset` is declared as a global 
variable, causing a debugfs dentry memory leak and unintended shared state 
across devices.
--

--- Patch [4]: [PATCH v13 4/4] drm/xe/ras: Use fault-inject to trigger 
cold-reset wedge ---
commit c174fc4eba36eef0c9a2a3c15d3daee0c0dbc948
Author: Mallesh Koujalagi <[email protected]>

drm/xe/ras: Use fault-inject to trigger cold-reset wedge

Use the fault-inject framework to trigger the cold-reset
wedge path (punit_error_handler()) for testing the
wedge/recovery flow.

> diff --git a/drivers/gpu/drm/xe/xe_debugfs.c b/drivers/gpu/drm/xe/xe_debugfs.c
> index 8de78cd0aa03b..acd34cc5dcbdb 100644
> --- a/drivers/gpu/drm/xe/xe_debugfs.c
> +++ b/drivers/gpu/drm/xe/xe_debugfs.c
> @@ -42,6 +42,7 @@
>  
>  DECLARE_FAULT_ATTR(gt_reset_failure);
>  DECLARE_FAULT_ATTR(inject_csc_hw_error);
> +DECLARE_FAULT_ATTR(wedge_cold_reset);

[Severity: Medium]
Since DECLARE_FAULT_ATTR() expands to a struct without the static keyword,
will this lead to kernel namespace pollution?

Also, because xe_fault_inject_debugfs_register() executes per-device,
will this globally shared attribute cause a debugfs dentry memory leak?

When fault_create_debugfs_attr() is called in the loop for each device:

drivers/gpu/drm/xe/xe_debugfs.c:xe_fault_inject_debugfs_register() {
        ...
                fault_create_debugfs_attr(xe_fault_inject_entry[i].name, root,
                                          xe_fault_inject_entry[i].attr);
        ...
}

Successive calls for multiple GPUs or during driver unbind/bind will overwrite
attr->dname with a newly referenced dentry without dropping the previous
reference.

This also means fault configurations will be shared across all devices rather
than being per-device. While this patch adds a new instance of an anti-pattern
already present in this file for the other attributes, is it possible to avoid
propagating it further?

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

Reply via email to