From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: platform/surface: gpe: use platform_device_register_full() Date: Sat, 16 May 2026 11:52:19 +1000 Message-ID: In-Reply-To: <20260513-swnode-remove-on-dev-unreg-v6-2-f9c58939df27@oss.qualcomm.com> References: <20260513-swnode-remove-on-dev-unreg-v6-0-f9c58939df27@oss.qualcomm.com> <20260513-swnode-remove-on-dev-unreg-v6-2-f9c58939df27@oss.qualcomm.com> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Patch Review **Bug: `surface_gpe_exit()` is not updated and will use-after-free.** The init conversion is clean -- replacing manual `fwnode_create_software_node()` + `platform_device_alloc()` + `platform_device_add()` with a single `platform_device_register_full()` using `.properties`: ```c pdevinfo = (struct platform_device_info){ .name = "surface_gpe", .id = PLATFORM_DEVID_NONE, .properties = match->driver_data, }; pdev = platform_device_register_full(&pdevinfo); ``` However, the existing `surface_gpe_exit()` (unchanged by this patch) still does: ```c static void __exit surface_gpe_exit(void) { struct fwnode_handle *fwnode = surface_gpe_device->dev.fwnode; platform_device_unregister(surface_gpe_device); platform_driver_unregister(&surface_gpe_driver); fwnode_remove_software_node(fwnode); } ``` With the old code, the fwnode was a standalone (non-managed) software node that persisted after `platform_device_unregister()`. With the new code, `platform_device_register_full()` with `.properties` calls `device_create_managed_software_node()`, which creates a **managed** node. During `platform_device_unregister()` -> `device_del()` -> `software_node_notify_remove()`, the managed node is cleaned up and its `kobject` refcount can reach zero, freeing the `swnode`. The subsequent `fwnode_remove_software_node(fwnode)` then dereferences freed memory. **Fix needed**: The exit function should be updated to remove the `fwnode_remove_software_node()` call and the saved `fwnode` pointer: ```c static void __exit surface_gpe_exit(void) { platform_device_unregister(surface_gpe_device); platform_driver_unregister(&surface_gpe_driver); } ``` --- --- Generated by Claude Code Patch Reviewer