When HPB pinned region exists and mctx allocation for this region fails, memory leak is possible because memory is not released for the subregion table of the current region. So, change to free memory for the subregion table of the current region. Signed-off-by: Keoseong Park <keosung.park@xxxxxxxxxxx> --- drivers/scsi/ufs/ufshpb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c index 9acce92a356b..052f584c789a 100644 --- a/drivers/scsi/ufs/ufshpb.c +++ b/drivers/scsi/ufs/ufshpb.c @@ -1933,7 +1933,7 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb) if (ufshpb_is_pinned_region(hpb, rgn_idx)) { ret = ufshpb_init_pinned_active_region(hba, hpb, rgn); if (ret) - goto release_srgn_table; + goto release_current_srgn_table; } else { rgn->rgn_state = HPB_RGN_INACTIVE; } @@ -1944,6 +1944,9 @@ static int ufshpb_alloc_region_tbl(struct ufs_hba *hba, struct ufshpb_lu *hpb) return 0; +release_current_srgn_table: + kvfree(rgn_table[rgn_idx].srgn_tbl); + release_srgn_table: for (i = 0; i < rgn_idx; i++) kvfree(rgn_table[i].srgn_tbl); -- 2.17.1