diff mbox series

[net] octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam

Message ID 1700930141-5568-1-git-send-email-sbhatta@marvell.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers fail 1 blamed authors not CCed: andrew@lunn.ch; 1 maintainers not CCed: andrew@lunn.ch
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Subbaraya Sundeep Nov. 25, 2023, 4:35 p.m. UTC
All the mailbox messages sent to AF needs to be guarded
by mutex lock. Add the missing lock in otx2_get_pauseparam
function.

Fixes: 75f36270990c ("octeontx2-pf: Support to enable/disable pause frames via ethtool")
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Simon Horman Nov. 28, 2023, 5:20 p.m. UTC | #1
On Sat, Nov 25, 2023 at 10:05:41PM +0530, Subbaraya Sundeep wrote:
> All the mailbox messages sent to AF needs to be guarded
> by mutex lock. Add the missing lock in otx2_get_pauseparam
> function.
> 
> Fixes: 75f36270990c ("octeontx2-pf: Support to enable/disable pause frames via ethtool")
> Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>

Hi,

I am wondering if the call to otx2_nix_config_bp()
in otx2_dcbnl_ieee_setpfc() also needs to be protected by mbox.lock.

And although not strictly related to this patch, while looking over this, I
noticed that in otx2_init_hw_resources() it appears that &mbox->lock may be
unlocked twice in some error paths.

e.g.
	/* Init Auras and pools used by NIX RQ, for free buffer ptrs */
	err = otx2_rq_aura_pool_init(pf);
	if (err) {
		mutex_unlock(&mbox->lock);
		goto err_free_nix_lf;
	}
	...
err_free_nix_lf:
	mutex_lock(&mbox->lock);
	...

...
Subbaraya Sundeep Nov. 29, 2023, 4:55 a.m. UTC | #2
Hi Simon,

>-----Original Message-----
>From: Simon Horman <horms@kernel.org>
>Sent: Tuesday, November 28, 2023 10:51 PM
>To: Subbaraya Sundeep Bhatta <sbhatta@marvell.com>
>Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org; kuba@kernel.org;
>davem@davemloft.net; pabeni@redhat.com; edumazet@google.com; Sunil
>Kovvuri Goutham <sgoutham@marvell.com>; Geethasowjanya Akula
><gakula@marvell.com>; Hariprasad Kelam <hkelam@marvell.com>
>Subject: [EXT] Re: [PATCH net] octeontx2-pf: Add missing mutex lock in
>otx2_get_pauseparam
>
>----------------------------------------------------------------------
>On Sat, Nov 25, 2023 at 10:05:41PM +0530, Subbaraya Sundeep wrote:
>> All the mailbox messages sent to AF needs to be guarded by mutex lock.
>> Add the missing lock in otx2_get_pauseparam function.
>>
>> Fixes: 75f36270990c ("octeontx2-pf: Support to enable/disable pause
>> frames via ethtool")
>> Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
>
>Hi,
>
>I am wondering if the call to otx2_nix_config_bp() in otx2_dcbnl_ieee_setpfc()
>also needs to be protected by mbox.lock.
>
Correct. I will add lock around it and send v2 of this patch.

>And although not strictly related to this patch, while looking over this, I
>noticed that in otx2_init_hw_resources() it appears that &mbox->lock may be
>unlocked twice in some error paths.
>
>e.g.
>	/* Init Auras and pools used by NIX RQ, for free buffer ptrs */
>	err = otx2_rq_aura_pool_init(pf);
>	if (err) {
>		mutex_unlock(&mbox->lock);
>		goto err_free_nix_lf;
>	}
>	...
>err_free_nix_lf:
>	mutex_lock(&mbox->lock);
>	...
>
>...
Will fix it and send it as another patch.

Thanks,
Sundeep
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 9efcec5..53f6258 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -334,9 +334,12 @@  static void otx2_get_pauseparam(struct net_device *netdev,
 	if (is_otx2_lbkvf(pfvf->pdev))
 		return;
 
+	mutex_lock(&pfvf->mbox.lock);
 	req = otx2_mbox_alloc_msg_cgx_cfg_pause_frm(&pfvf->mbox);
-	if (!req)
+	if (!req) {
+		mutex_unlock(&pfvf->mbox.lock);
 		return;
+	}
 
 	if (!otx2_sync_mbox_msg(&pfvf->mbox)) {
 		rsp = (struct cgx_pause_frm_cfg *)
@@ -344,6 +347,7 @@  static void otx2_get_pauseparam(struct net_device *netdev,
 		pause->rx_pause = rsp->rx_pause;
 		pause->tx_pause = rsp->tx_pause;
 	}
+	mutex_unlock(&pfvf->mbox.lock);
 }
 
 static int otx2_set_pauseparam(struct net_device *netdev,