Skip to content

Commit 6c9783e

Browse files
keosungmartinkpetersen
authored andcommitted
scsi: ufs: ufshpb: Fix possible memory leak
When HPB pinned region exists and mctx allocation for this region fails, a memory leak is possible because memory is not released for the subregion table of the current region. Free memory for the subregion table of the current region. Link: https://lore.kernel.org/r/1891546521.01629711601304.JavaMail.epsvc@epcpadp3 Reviewed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Keoseong Park <keosung.park@samsung.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 1259d5f commit 6c9783e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/scsi/ufs/ufshpb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,8 +1904,6 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb)
19041904
if (!rgn_table)
19051905
return -ENOMEM;
19061906

1907-
hpb->rgn_tbl = rgn_table;
1908-
19091907
for (rgn_idx = 0; rgn_idx < hpb->rgns_per_lu; rgn_idx++) {
19101908
int srgn_cnt = hpb->srgns_per_rgn;
19111909
bool last_srgn = false;
@@ -1942,10 +1940,12 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb)
19421940
rgn->hpb = hpb;
19431941
}
19441942

1943+
hpb->rgn_tbl = rgn_table;
1944+
19451945
return 0;
19461946

19471947
release_srgn_table:
1948-
for (i = 0; i < rgn_idx; i++)
1948+
for (i = 0; i <= rgn_idx; i++)
19491949
kvfree(rgn_table[i].srgn_tbl);
19501950

19511951
kvfree(rgn_table);

0 commit comments

Comments
 (0)