[PATCH] drm/xe/xe_pmu: Add a null check for xe gt
Riana Tauro
riana.tauro at intel.com
Wed Apr 16 06:05:31 UTC 2025
The PMU initialization function exits if gt is invalid,
eliminating the need for additional checks. However, absence
of these checks causes static analysis tool warnings
Add a null check for gt to avoid static analysis tool warnings
Signed-off-by: Riana Tauro <riana.tauro at intel.com>
---
drivers/gpu/drm/xe/xe_pmu.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
index 69df0e3520a5..5550ed30018f 100644
--- a/drivers/gpu/drm/xe/xe_pmu.c
+++ b/drivers/gpu/drm/xe/xe_pmu.c
@@ -141,6 +141,8 @@ static bool event_gt_forcewake(struct perf_event *event)
return true;
gt = xe_device_get_gt(xe, config_to_gt_id(config));
+ if (!gt)
+ return false;
fw_ref = kzalloc(sizeof(*fw_ref), GFP_KERNEL);
if (!fw_ref)
@@ -211,11 +213,10 @@ static bool event_param_valid(struct perf_event *event)
static void xe_pmu_event_destroy(struct perf_event *event)
{
struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base);
- struct xe_gt *gt;
unsigned int *fw_ref = event->pmu_private;
+ struct xe_gt *gt = xe_device_get_gt(xe, config_to_gt_id(event->attr.config));
- if (fw_ref) {
- gt = xe_device_get_gt(xe, config_to_gt_id(event->attr.config));
+ if (fw_ref && gt) {
xe_force_wake_put(gt_to_fw(gt), *fw_ref);
kfree(fw_ref);
event->pmu_private = NULL;
--
2.47.1
More information about the Intel-xe
mailing list