All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Zhengchao Shao <shaozhengchao@huawei.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<edumazet@google.com>, <pabeni@redhat.com>, <jiri@mellanox.com>,
	<weiyongjun1@huawei.com>, <yuehaibing@huawei.com>
Subject: Re: [PATCH net 1/2] netdevsim: fix memory leak in nsim_drv_probe() when nsim_dev_resources_register() failed
Date: Thu, 20 Oct 2022 17:26:12 -0700	[thread overview]
Message-ID: <20221020172612.0a8e60bb@kernel.org> (raw)
In-Reply-To: <20221020023358.263414-2-shaozhengchao@huawei.com>

On Thu, 20 Oct 2022 10:33:57 +0800 Zhengchao Shao wrote:
> Fixes: 8fb4bc6fd5bd ("netdevsim: rename devlink.c to dev.c to contain per-dev(asic) items")

Looks like a rename patch.

The Fixes tag must point to the commit which introduced the bug.

> diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c
> index 794fc0cc73b8..39231c5319de 100644
> --- a/drivers/net/netdevsim/dev.c
> +++ b/drivers/net/netdevsim/dev.c
> @@ -1554,7 +1554,7 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>  
>  	err = nsim_dev_resources_register(devlink);
>  	if (err)
> -		goto err_vfc_free;
> +		goto err_dl_unregister;

It's better to add the devl_resources_unregister() call to the error
path of nsim_dev_resources_register(). There should be no need to clean
up after functions when they fail.

>  	err = devlink_params_register(devlink, nsim_devlink_params,
>  				      ARRAY_SIZE(nsim_devlink_params));
> @@ -1627,7 +1627,6 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev)
>  				  ARRAY_SIZE(nsim_devlink_params));
>  err_dl_unregister:
>  	devl_resources_unregister(devlink);
> -err_vfc_free:
>  	kfree(nsim_dev->vfconfigs);

  reply	other threads:[~2022-10-21  0:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  2:33 [PATCH net 0/2] fix some issues in netdevsim driver Zhengchao Shao
2022-10-20  2:33 ` [PATCH net 1/2] netdevsim: fix memory leak in nsim_drv_probe() when nsim_dev_resources_register() failed Zhengchao Shao
2022-10-21  0:26   ` Jakub Kicinski [this message]
2022-10-21  8:28     ` shaozhengchao
2022-10-21  9:13       ` shaozhengchao
2022-10-21 15:21         ` Jakub Kicinski
2022-10-22  4:30           ` shaozhengchao
2022-10-20  2:33 ` [PATCH net 2/2] netdevsim: remove dir in nsim_dev_debugfs_init() when creating ports dir failed Zhengchao Shao

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20221020172612.0a8e60bb@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shaozhengchao@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=yuehaibing@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.