]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: use devm_add_action_or_reset() helper
authorHe Lugang <helugang@uniontech.com>
Wed, 11 Sep 2024 10:22:15 +0000 (18:22 +0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 3 Oct 2024 06:13:54 +0000 (01:13 -0500)
Use devm_add_action_or_reset() to release resources in case of failure,
because the cleanup function will be automatically called.

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: He Lugang <helugang@uniontech.com>
Link: https://patchwork.freedesktop.org/patch/msgid/9631BC17D1E028A2+20240911102215.84865-1-helugang@uniontech.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
(cherry picked from commit fdc81c43f0c14ace6383024a02585e3fcbd1ceba)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_gt_freq.c
drivers/gpu/drm/xe/xe_gt_sysfs.c

index 68a5778b4319fde12cb1b520c95b64f2a89c1792..ab76973f3e1e6fe19057711c65a42dd668066ba8 100644 (file)
@@ -237,11 +237,11 @@ int xe_gt_freq_init(struct xe_gt *gt)
        if (!gt->freq)
                return -ENOMEM;
 
-       err = devm_add_action(xe->drm.dev, freq_fini, gt->freq);
+       err = sysfs_create_files(gt->freq, freq_attrs);
        if (err)
                return err;
 
-       err = sysfs_create_files(gt->freq, freq_attrs);
+       err = devm_add_action_or_reset(xe->drm.dev, freq_fini, gt->freq);
        if (err)
                return err;
 
index a05c3699e8b9149d9caa8683d832c8f8cb1244ac..ec2b8246204b88ec9d1b818f54b4f93ab93058f6 100644 (file)
@@ -51,5 +51,5 @@ int xe_gt_sysfs_init(struct xe_gt *gt)
 
        gt->sysfs = &kg->base;
 
-       return devm_add_action(xe->drm.dev, gt_sysfs_fini, gt);
+       return devm_add_action_or_reset(xe->drm.dev, gt_sysfs_fini, gt);
 }