From: Christophe JAILLET Date: Sun, 20 Jun 2021 09:49:40 +0000 (+0200) Subject: net: hns3: Fix a memory leak in an error handling path in 'hclge_handle_error_info_log()' X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=b40d7af798a0a459d65bd95f34e3dff004eb554a;p=linux.git net: hns3: Fix a memory leak in an error handling path in 'hclge_handle_error_info_log()' If this 'kzalloc()' fails we must free some resources as in all the other error handling paths of this function. Fixes: 2e2deee7618b ("net: hns3: add the RAS compatibility adaptation solution") Signed-off-by: Christophe JAILLET Reviewed-by: Jiaran Zhang Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index bad9fda19398b..ec9a7f8bc3fed 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -2330,8 +2330,10 @@ int hclge_handle_error_info_log(struct hnae3_ae_dev *ae_dev) buf_size = buf_len / sizeof(u32); desc_data = kzalloc(buf_len, GFP_KERNEL); - if (!desc_data) - return -ENOMEM; + if (!desc_data) { + ret = -ENOMEM; + goto err_desc; + } buf = kzalloc(buf_len, GFP_KERNEL); if (!buf) {