[PATCH 16/20] net/sfc: fix a memory leak in error handling
Weiguo Li
liwg06 at foxmail.com
Tue Feb 22 19:18:14 CET 2022
When efx_nic_get_board_info() failed then function return, the
memory in 'id' is not released, this leads to a memory leak.
Fixes: e86b48aa46d4 ("net/sfc: add HW switch ID helpers")
Signed-off-by: Weiguo Li <liwg06 at foxmail.com>
---
drivers/net/sfc/sfc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 51726d229b..ad1683a512 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -1423,8 +1423,10 @@ sfc_hw_switch_id_init(struct sfc_adapter *sa,
return ENOMEM;
rc = efx_nic_get_board_info(sa->nic, &board_info);
- if (rc != 0)
+ if (rc != 0) {
+ rte_free(id);
return rc;
+ }
memcpy(id->board_sn, board_info.enbi_serial, sizeof(id->board_sn));
--
2.25.1
More information about the dev
mailing list