Skip to contentSkip to conversation

net: ethernet: marvell: octeontx2: nic: Add error pointer check in otx2_common.c

PATCH In review Dipendra Khadka 2 participants 4 messages Sep 23, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ethernet: marvell: octeontx2: nic: Add error pointer check in otx2_common.c

Add error pointer check after calling otx2_mbox_get_rsp().

---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -0
index 87d5776e3b88..6e5f1b2e8c52 100644
@@ -1838,6 +1838,11 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
 		rsp = (struct nix_hw_info *)
 		       otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
 
+		if (IS_ERR(rsp)) {
+			mutex_unlock(&pfvf->mbox.lock);
+			return PTR_ERR(rsp);
+		}
+
 		/* HW counts VLAN insertion bytes (8 for double tag)
 		 * irrespective of whether SQE is requesting to insert VLAN
 		 * in the packet or not. Hence these 8 bytes have to be
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/1 net: ethernet: marvell: octeontx2: nic: Add error pointer check in otx2_common.c

---------- Forwarded message ---------
From: Dipendra Khadka <[email protected]>
Date: Mon, 23 Sept 2024 at 16:51
Subject: [PATCH net] net: ethernet: marvell: octeontx2: nic: Add error pointer check in otx2_common.c
To: <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Cc: Dipendra Khadka <[email protected]>, <[email protected]>, <[email protected]>

Add error pointer check after calling otx2_mbox_get_rsp().

---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 5 +++++
 1 file changed, 5 insertions(+)
(quoted diff) +0 -0

b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c index 87d5776e3b88..6e5f1b2e8c52 100644

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +5 -0
@@ -1838,6 +1838,11 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
                rsp = (struct nix_hw_info *)
                       otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
 
+               if (IS_ERR(rsp)) {
+                       mutex_unlock(&pfvf->mbox.lock);
+                       return PTR_ERR(rsp);
+               }
+
                /* HW counts VLAN insertion bytes (8 for double tag)
                 * irrespective of whether SQE is requesting to insert VLAN
                 * in the packet or not. Hence these 8 bytes have to be

--
2.43.0

#2 lore raw
In reply to Dipendra Khadka

Hi,

Quoted 1 line · On Mon, 23 Sep 2024 11:06:32 +0000 Dipendra Khadka <[email protected]>…

Add error pointer check after calling otx2_mbox_get_rsp().

As this is a fix, you need a Fixes: tag.

Quoted 10 lines
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +0 -0
index 87d5776e3b88..6e5f1b2e8c52 100644

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c u16 otx2_get_max_mtu(struct otx2_nic *pfvf) · line 1844

Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +4 -0
@@ -1838,6 +1838,11 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
 		rsp = (struct nix_hw_info *)
 		       otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
 
+		if (IS_ERR(rsp)) {
+			mutex_unlock(&pfvf->mbox.lock);
+			return PTR_ERR(rsp);
+		}

You're returning an error code as the max MTU, which will be propagated to netdev->max_mtu, that's not correct. There's already an error path in this function that you can use.

Thanks,

Maxime

#3 lore raw

Hi,

Quoted 23 lines · Maxime Chevallier

Hi,

Quoted 1 line · On Mon, 23 Sep 2024 11:06:32 +0000 Dipendra Khadka <[email protected]>…

Add error pointer check after calling otx2_mbox_get_rsp().

As this is a fix, you need a Fixes: tag.

Quoted 13 lines
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +0 -0
index 87d5776e3b88..6e5f1b2e8c52 100644
@@ -1838,6 +1838,11 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
              rsp = (struct nix_hw_info *)
                     otx2_mbox_get_rsp(&pfvf->mbox.mbox, 0, &req->hdr);
 
Quoted 9 lines

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c u16 otx2_get_max_mtu(struct otx2_nic *pfvf) · line 1844

Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +4 -0
+             if (IS_ERR(rsp)) {
+                     mutex_unlock(&pfvf->mbox.lock);
+                     return PTR_ERR(rsp);
+             }

You're returning an error code as the max MTU, which will be propagated to netdev->max_mtu, that's not correct. There's already an error path in this function that you can use.

Sure, thanks for the response. I will send a v2 .

Quoted 3 lines

Thanks,

Maxime

Best regards,
Dipendra