lkml.org 
[lkml]   [2018]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mlxsw: core: Fix an error handling path in 'mlxsw_core_bus_device_register()'
On Thu, May 10, 2018 at 01:26:16PM +0200, Christophe JAILLET wrote:
> Resources are not freed in the reverse order of the allocation.
> Labels are also mixed-up.
>
> Fix it and reorder code and labels in the error handling path of
> 'mlxsw_core_bus_device_register()'
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Please review carefully. This patch is proposed because it triggers one of
> my coccinelle scripts. I'm not 100% sure if correct.
>

Looks correct.

The err = mlxsw_driver->resources_register(mlxsw_core); pointer is a
pointer to mlxsw_sp_resources_register(). That function doesn't clean
up after itself on failure. Ideally, you'd want a matching
mlxsw_driver->resources_unregister as well pointer instead of hard
coding devlink_resources_unregister().

The error handling would be easier to review if the gotos told you what
the did. Right now they're written in "come from" style so the tell you
what happened on the line before.

if (!foo)
goto allocating_foo_failed;

Hopefully if someone fixes mlxsw_sp_resources_register() they'll choose
better label names.

regards,
dan carpenter

\
 
 \ /
  Last update: 2018-05-10 14:42    [W:0.067 / U:0.788 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site