Skip to content

Commit bfb7789

Browse files
Xiaomeng Tongmartinkpetersen
authored andcommitted
scsi: ufs: ufshpb: Fix a NULL check on list iterator
The list iterator is always non-NULL so the check 'if (!rgn)' is always false and the dev_err() is never called. Move the check outside the loop and determine if 'victim_rgn' is NULL, to fix this bug. Link: https://lore.kernel.org/r/20220320150733.21824-1-xiam0nd.tong@gmail.com Fixes: 4b5f490 ("scsi: ufs: ufshpb: L2P map management for HPB read") Reviewed-by: Daejun Park <daejun7.park@samsung.com> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 0325225 commit bfb7789

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/scsi/ufs/ufshpb.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
867867
struct ufshpb_region *rgn, *victim_rgn = NULL;
868868

869869
list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
870-
if (!rgn) {
871-
dev_err(&hpb->sdev_ufs_lu->sdev_dev,
872-
"%s: no region allocated\n",
873-
__func__);
874-
return NULL;
875-
}
876870
if (ufshpb_check_srgns_issue_state(hpb, rgn))
877871
continue;
878872

@@ -888,6 +882,11 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
888882
break;
889883
}
890884

885+
if (!victim_rgn)
886+
dev_err(&hpb->sdev_ufs_lu->sdev_dev,
887+
"%s: no region allocated\n",
888+
__func__);
889+
891890
return victim_rgn;
892891
}
893892

0 commit comments

Comments
 (0)