[07/11] net/nfp: add the check about the firmware load

Message ID 20231102022321.2254224-8-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Add the support of multiple PF |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Nov. 2, 2023, 2:23 a.m. UTC
  From: Peng Zhang <peng.zhang@corigine.com>

When firmware load failed, it doesn't have any notice.
So add the check about the firmware load and add an exit
point when the firmware load process fail.

Signed-off-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
---
 drivers/net/nfp/nfp_ethdev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 3ebfd444b3..9378a2ebc3 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -654,7 +654,12 @@  nfp_fw_upload(struct rte_pci_device *dev,
 	PMD_DRV_LOG(INFO, "Firmware file found at %s with size: %zu",
 			fw_name, fsize);
 	PMD_DRV_LOG(INFO, "Uploading the firmware ...");
-	nfp_nsp_load_fw(nsp, fw_buf, fsize);
+	if (nfp_nsp_load_fw(nsp, fw_buf, fsize) < 0) {
+		free(fw_buf);
+		PMD_DRV_LOG(ERR, "Firmware load failed.");
+		return -EIO;
+	}
+
 	PMD_DRV_LOG(INFO, "Done");
 
 	free(fw_buf);