Skip to contentSkip to conversation

enic: initialize 'a1' argument to vnic_dev_cmd

PATCH In review Satish Kharat 2 participants 2 messages Apr 23, 2024 – Apr 24, 2024

Subsystems (3)
lore
Share & tools
lore

Satish Kharat

author maintainer
#0 lore raw

PATCH 1/1 enic: initialize 'a1' argument to vnic_dev_cmd

Always initialize the 'a1' argument passed to
vnic_dev_cmd, keep it consistent.

---
 drivers/net/ethernet/cisco/enic/vnic_dev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/cisco/enic/vnic_dev.c +4 -3
index 12a83fa1302d..288cbc3fa4fc 100644
@@ -718,14 +718,14 @@ int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done)
 
 int vnic_dev_hang_notify(struct vnic_dev *vdev)
 {
-	u64 a0, a1;
+	u64 a0 = 0, a1 = 0;
 	int wait = 1000;
 	return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait);
 }
 
 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-	u64 a0, a1;
+	u64 a0 = 0, a1 = 0;
 	int wait = 1000;
 	int err, i;
 
@@ -1164,7 +1164,7 @@ int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status)
 
 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-	u64 a0, a1;
+	u64 a0, a1 = 0;
 	int wait = 1000;
 	int i;
 
@@ -1230,6 +1230,7 @@ int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
 		dma_free_coherent(&vdev->pdev->dev, tlv_size, tlv_va, tlv_pa);
 	} else if (cmd == CLSF_DEL) {
 		a0 = *entry;
+		a1 = 0;
 		ret = vnic_dev_cmd(vdev, CMD_DEL_FILTER, &a0, &a1, wait);
 	}
 
Signature · 1 line
2.44.0
reviewer
#1 lore raw
Quoted 2 lines · Satish Kharat

Always initialize the 'a1' argument passed to
vnic_dev_cmd, keep it consistent.

Hi Satish,

I think this patch also addresses cases where a0 are passed uninitialised, so probably that should be mentioned too.

Also, I think it would be worth explaining a bit more about why this change is being made. Does it resolve a bug? If not, perhaps mention why.

The comments above and below notwithstanding,
I agree that the code changes are correct.

Quoted 36 lines
---
 drivers/net/ethernet/cisco/enic/vnic_dev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/cisco/enic/vnic_dev.c +3 -3
index 12a83fa1302d..288cbc3fa4fc 100644
@@ -718,14 +718,14 @@ int vnic_dev_hang_reset_done(struct vnic_dev *vdev, int *done)
 
 int vnic_dev_hang_notify(struct vnic_dev *vdev)
 {
-	u64 a0, a1;
+	u64 a0 = 0, a1 = 0;
 	int wait = 1000;
 	return vnic_dev_cmd(vdev, CMD_HANG_NOTIFY, &a0, &a1, wait);
 }
 
 int vnic_dev_get_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-	u64 a0, a1;
+	u64 a0 = 0, a1 = 0;
 	int wait = 1000;
 	int err, i;
 
@@ -1164,7 +1164,7 @@ int vnic_dev_deinit_done(struct vnic_dev *vdev, int *status)
 
 int vnic_dev_set_mac_addr(struct vnic_dev *vdev, u8 *mac_addr)
 {
-	u64 a0, a1;
+	u64 a0, a1 = 0;
 	int wait = 1000;
 	int i;
 

drivers/net/ethernet/cisco/enic/vnic_dev.c int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry, · line 1233

Quoted 4 lines
drivers/net/ethernet/cisco/enic/vnic_dev.c +1 -0
@@ -1230,6 +1230,7 @@ int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
 		dma_free_coherent(&vdev->pdev->dev, tlv_size, tlv_va, tlv_pa);
 	} else if (cmd == CLSF_DEL) {
 		a0 = *entry;
+		a1 = 0;

Assuming this is not a bug fix, while we are here the scope of the declaration of a0 and a1 could be reduced to this block.

Quoted 7 lines
drivers/net/ethernet/cisco/enic/vnic_dev.c +0 -0
 		ret = vnic_dev_cmd(vdev, CMD_DEL_FILTER, &a0, &a1, wait);
 	}
 
Signature · 1 line
2.44.0