Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1688137
| From | Christophe JAILLET <christophe.jaillet@wanadoo.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/3] thermal: core: Reorder 'thermal_zone_device_register()' error handling code |
| Date | 2017-07-16 09:00 +0200 |
| Message-ID | <u3LH4-3He-21@gated-at.bofh.it> (permalink) |
| References | <u3LH3-3He-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Reorder code in the error handling path in order to match the way resources have been allocated. With this new order, we can avoid a call to 'device_unregister()' if 'thermal_zone_create_device_groups'()' fails. At this point, 'device_register()' has not been called yet. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- drivers/thermal/thermal_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9743f3e65eb0..c58714800660 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -1232,7 +1232,7 @@ thermal_zone_device_register(const char *type, int trips, int mask, /* Add nodes that are always present via .groups */ result = thermal_zone_create_device_groups(tz, mask); if (result) - goto unregister; + goto remove_id; /* A new thermal zone needs to be updated anyway. */ atomic_set(&tz->need_update, 1); @@ -1294,8 +1294,9 @@ thermal_zone_device_register(const char *type, int trips, int mask, return tz; unregister: - ida_simple_remove(&thermal_tz_ida, tz->id); device_unregister(&tz->device); +remove_id: + ida_simple_remove(&thermal_tz_ida, tz->id); kfree(tz); return ERR_PTR(result); } -- 2.11.0
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH 1/3] thermal: core: Fix a memory leak in 'thermal_zone_device_register()' error handling path Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-07-16 09:00 +0200 [PATCH 3/3] thermal: core: Avoid code duplication in 'thermal_zone_device_register()' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-07-16 09:00 +0200 [PATCH 2/3] thermal: core: Reorder 'thermal_zone_device_register()' error handling code Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-07-16 09:00 +0200
csiph-web