On Wed, Mar 11, 2026 at 01:35:07AM +0530, Sanjay Chitroda wrote:
Replace manual cleanup logic with __free attribute from cleanup.h. This removes explicit kfree() calls and simplifies the error handling paths.
No functional change intended for kmalloc().
...
- struct gb_camera_configure_streams_request *req __free(kfree) =
kmalloc(req_size, GFP_KERNEL);- struct gb_camera_configure_streams_response *resp __free(kfree) =
if (!req || !resp) {kmalloc(resp_size, GFP_KERNEL);
Now this check should be done in a better way.
kfree(req); return -ENOMEM; }kfree(resp);
done_skip_pm_put: mutex_unlock(&gcam->mutex);
To complete this, one may add a prerequisite to use guard()() first.
- kfree(req);
- kfree(resp); return ret;
}