44 lines
1.3 KiB
Diff
44 lines
1.3 KiB
Diff
From 0c9553324e815f7a2814b223d28c1b29ab4f4011 Mon Sep 17 00:00:00 2001
|
|
From: Weili Qian <qianweili@huawei.com>
|
|
Date: Mon, 10 Jul 2023 11:47:16 +0800
|
|
Subject: [PATCH 05/26] drv/qm: fix memory leak in hisi_qm_create_sglpool()
|
|
|
|
In 'hisi_qm_create_sglpool()', if 'hisi_qm_create_sgl() failed',
|
|
current 'sgl_pool->sgl_num == 0', the 'hisi_qm_free_sglpool()'
|
|
cannot release the applied sgl.
|
|
|
|
Signed-off-by: Weili Qian <qianweili@huawei.com>
|
|
---
|
|
drv/hisi_qm_udrv.c | 7 ++++---
|
|
1 file changed, 4 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/drv/hisi_qm_udrv.c b/drv/hisi_qm_udrv.c
|
|
index acc2877..d86a692 100644
|
|
--- a/drv/hisi_qm_udrv.c
|
|
+++ b/drv/hisi_qm_udrv.c
|
|
@@ -648,8 +648,7 @@ static void hisi_qm_free_sglpool(struct hisi_sgl_pool *pool)
|
|
|
|
if (pool->sgl) {
|
|
for (i = 0; i < pool->sgl_num; i++)
|
|
- if (pool->sgl[i])
|
|
- free(pool->sgl[i]);
|
|
+ free(pool->sgl[i]);
|
|
|
|
free(pool->sgl);
|
|
}
|
|
@@ -692,8 +691,10 @@ handle_t hisi_qm_create_sglpool(__u32 sgl_num, __u32 sge_num)
|
|
/* base the sgl_num create the sgl chain */
|
|
for (i = 0; i < sgl_num; i++) {
|
|
sgl_pool->sgl[i] = hisi_qm_create_sgl(sge_num);
|
|
- if (!sgl_pool->sgl[i])
|
|
+ if (!sgl_pool->sgl[i]) {
|
|
+ sgl_pool->sgl_num = i;
|
|
goto err_out;
|
|
+ }
|
|
|
|
sgl_pool->sgl_align[i] = hisi_qm_align_sgl(sgl_pool->sgl[i],
|
|
sge_num);
|
|
--
|
|
2.25.1
|
|
|