Re: [PATCH] cxl/port: automate cleanup with __free()
From: Dan Williams
Date: Tue Jun 24 2025 - 13:12:13 EST
Pranav Tyagi wrote:
> Use the scope based resource management (defined in linux/cleanup.h) to
> automate the lifetime control of struct cxl_endpoint_decoder. This
> eliminates the explicit kfree() call and makes the code more robust and
> maintainable in presence of early returns.
I do not want to review small standalone conversions of individual
functions for no other reason than vague claims of improvement. The
reasons to convert an existing function to cleanup.h helpers are:
1/ to fix an actual bug
2/ in the course of refactoring the code for other reasons
3/ to eliminate goto trickiness and bulk
This patch does not make the code "more robust and maintainable", it is
just churn given how easy it is to verify that the kfree() is correctly
paired.
One quick way to identify code churn is when the diffstat does not
result in a net reduction in code lines:
This patch is "3 insertions(+), 3 deletions(-)" == "churn".