scsi: ufs: ufshpb: Fix a NULL check on list iterator
authorXiaomeng Tong <xiam0nd.tong@gmail.com>
Sun, 20 Mar 2022 15:07:33 +0000 (23:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 18:59:19 +0000 (20:59 +0200)
commit685f42de443d5bb8a81cc238c6047873f1aebaeb
tree7a0ac9ea44be0fcad441e6f6abccfc1adb7af941
parenta972c768723359ec995579902473028fe3cd64b1
scsi: ufs: ufshpb: Fix a NULL check on list iterator

[ Upstream commit bfb7789bcbd901caead43861461bc8f334c90d3b ]

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: 4b5f49079c52 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/ufs/ufshpb.c