From: Leon Romanovsky <leon@kernel.org>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com,
Mateusz Palczewski <mateusz.palczewski@intel.com>,
netdev@vger.kernel.org, Gurucharan G <gurucharanx.g@intel.com>
Subject: Re: [PATCH net v2 2/3] ice: Fix deadlock on the rtnl_mutex
Date: Wed, 4 Jan 2023 09:44:35 +0200 [thread overview]
Message-ID: <Y7UuY1J9vk0gFCG+@unreal> (raw)
In-Reply-To: <20230103230738.1102585-3-anthony.l.nguyen@intel.com>
On Tue, Jan 03, 2023 at 03:07:37PM -0800, Tony Nguyen wrote:
> From: Mateusz Palczewski <mateusz.palczewski@intel.com>
>
> There is a deadlock on rtnl_mutex when attempting to take the lock
> in unregister_netdev() after it has already been taken by
> ethnl_set_channels(). This happened when unregister_netdev() was
> called inside of ice_vsi_rebuild().
> Fix that by removing the unregister_netdev() usage and replace it with
> ice_vsi_clear_rings() that deallocates the tx and rx rings for the VSI.
>
> Fixes: df0f847915b4 ("ice: Move common functions out of ice_main.c part 6/7")
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
> Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_lib.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 94aa834cd9a6..22bcb414546a 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c
> @@ -3619,12 +3619,10 @@ int ice_vsi_rebuild(struct ice_vsi *vsi, bool init_vsi)
> err_vectors:
> ice_vsi_free_q_vectors(vsi);
> err_rings:
> - if (vsi->netdev) {
> - vsi->current_netdev_flags = 0;
> - unregister_netdev(vsi->netdev);
> - free_netdev(vsi->netdev);
> - vsi->netdev = NULL;
> - }
> + ice_vsi_clear_rings(vsi);
> + set_bit(ICE_RESET_FAILED, pf->state);
> + kfree(coalesce);
> + return ret;
> err_vsi:
This is very odd error unwind idiom only to perform:
if (something)
ice_vsi_clear_rings(vsi);
else
ice_vsi_clear(vsi);
Please avoid putting "return ..." and same code in the middle of goto unwind.
Thanks
> ice_vsi_clear(vsi);
> set_bit(ICE_RESET_FAILED, pf->state);
> --
> 2.38.1
>
next prev parent reply other threads:[~2023-01-04 7:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 23:07 [PATCH net v2 0/3][pull request] Intel Wired LAN Driver Updates 2023-01-03 (ice) Tony Nguyen
2023-01-03 23:07 ` [PATCH net v2 1/3] ice: Prevent set_channel from changing queues while RDMA active Tony Nguyen
2023-01-04 7:45 ` Leon Romanovsky
2023-01-05 4:42 ` Jakub Kicinski
2023-01-03 23:07 ` [PATCH net v2 2/3] ice: Fix deadlock on the rtnl_mutex Tony Nguyen
2023-01-04 7:44 ` Leon Romanovsky [this message]
2023-01-03 23:07 ` [PATCH net v2 3/3] ice: Fix broken link in ice NAPI doc Tony Nguyen
2023-01-04 2:02 ` Bagas Sanjaya
2023-01-05 4:43 ` Jakub Kicinski
2023-01-09 8:54 ` Wilczynski, Michal
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=Y7UuY1J9vk0gFCG+@unreal \
--to=leon@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gurucharanx.g@intel.com \
--cc=kuba@kernel.org \
--cc=mateusz.palczewski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 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).