LKML Archive on
help / color / mirror / Atom feed
From: Dan Carpenter <>
To: Christophe JAILLET <>
Subject: Re: [PATCH] mlxsw: core: Fix an error handling path in 'mlxsw_core_bus_device_register()'
Date: Thu, 10 May 2018 15:41:39 +0300	[thread overview]
Message-ID: <20180510124138.6yerbsfcl3abqtmq@mwanda> (raw)
In-Reply-To: <>

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 <>
> ---
> 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.

dan carpenter

      parent reply	other threads:[~2018-05-10 12:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 11:26 Christophe JAILLET
2018-05-10 11:58 ` Ido Schimmel
2018-05-11 15:57   ` David Miller
2018-05-10 12:41 ` Dan Carpenter [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180510124138.6yerbsfcl3abqtmq@mwanda \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] mlxsw: core: Fix an error handling path in '\''mlxsw_core_bus_device_register()'\''' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).