On Sat, May 8, 2021 at 1:23 AM Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> wrote: > > If 'acpi_device_set_name()' fails, we must free > 'acpi_device_bus_id->bus_id' or there is a (potential) memory leak. This is a question about the style used in kernel. This function (acpi_device_add) initializes acpi_device_bus_id and it could also initialize acpi_device_bus_id->bus_id and any of those might fail. And they will have to be freed if they are initialized and so on. I see that there are kfrees used for them in different places before using a goto err_unlock; I wonder if it is accepted practice to avoid doing these kfrees and have them in a single place instead, something like: err_onlock: if (acpi_device_bus_id) { if (acpi_device_bus_id->bus_id) kfree(acpi_device_bus_id->bus_id); kfree(acpi_device_bus_id); } mutex_unlock(&acpi_device_lock); . . . Thanks in advance.