[PATCH V8 43/43] drm/colorop: Add destroy functions for color pipeline

Alex Hung alex.hung at amd.com
Tue Apr 1 02:42:50 UTC 2025



On 3/29/25 09:48, Simon Ser wrote:
> I would prefer these functions to be introduced together with the
> patches adding functions to create objects and adding the new fields.
> That way it's easier to check the symmetry and at no point in the
> series there are memory leaks.

The object creation and new fields are introduced in different patches. 
I divided this patch by introducing these functions in a patch, and 2. 
adding callers when needed to avoid memory leaks.

> 
> Additionally, I would avoid using the name "cleanup", which seems to
> have different semantics: for instance drm_plane_cleanup() doesn't kfree
> the pointer. "destroy" seems more appropriate here.

How about the following changes, i.e., freeing pointer is moved out of 
the cleanup function, and keeping the names.

@@ -173,7 +173,6 @@ static void drm_colorop_cleanup(struct drm_colorop 
*colorop)
         }

         kfree(colorop->state);
-       kfree(colorop);
  }

  /**
@@ -191,6 +190,7 @@ void drm_colorop_pipeline_destroy(struct drm_plane 
*plane)

         list_for_each_entry_safe(colorop, next, &config->colorop_list, 
head) {
                 drm_colorop_cleanup(colorop);
+               kfree(colorop);
         }
  }




More information about the amd-gfx mailing list