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>
This commit is contained in:
parent
1259d5f0f5
commit
6c9783e629
|
@ -1904,8 +1904,6 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb)
|
|||
if (!rgn_table)
|
||||
return -ENOMEM;
|
||||
|
||||
hpb->rgn_tbl = rgn_table;
|
||||
|
||||
for (rgn_idx = 0; rgn_idx < hpb->rgns_per_lu; rgn_idx++) {
|
||||
int srgn_cnt = hpb->srgns_per_rgn;
|
||||
bool last_srgn = false;
|
||||
|
@ -1942,10 +1940,12 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb)
|
|||
rgn->hpb = hpb;
|
||||
}
|
||||
|
||||
hpb->rgn_tbl = rgn_table;
|
||||
|
||||
return 0;
|
||||
|
||||
release_srgn_table:
|
||||
for (i = 0; i < rgn_idx; i++)
|
||||
for (i = 0; i <= rgn_idx; i++)
|
||||
kvfree(rgn_table[i].srgn_tbl);
|
||||
|
||||
kvfree(rgn_table);
|
||||
|
|
Loading…
Reference in New Issue