* [PATCH v2] ufs: fix an NULL check on list iterator
@ 2022-03-20 15:07 ` Xiaomeng Tong
2022-03-21 13:17 ` Daejun Park
0 siblings, 1 reply; 2+ messages in thread
From: Xiaomeng Tong @ 2022-03-20 15:07 UTC (permalink / raw)
To: alim.akhtar
Cc: avri.altman, jejb, martin.petersen, daejun7.park, beanhuo,
bvanassche, keosung.park, gregkh, stanley.chu, linux-scsi,
linux-kernel, jakobkoschel, Xiaomeng Tong
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.
Fixes: 4b5f49079c52a ("scsi: ufs: ufshpb: L2P map management for HPB read")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
---
changes since v1:
- move the check outside the loop (Jakob Koschel)
v1: https://lore.kernel.org/all/20220319042657.21835-1-xiam0nd.tong@gmail.com/
---
drivers/scsi/ufs/ufshpb.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/ufs/ufshpb.c b/drivers/scsi/ufs/ufshpb.c
index 2d36a0715fca..b34feba1f53d 100644
--- a/drivers/scsi/ufs/ufshpb.c
+++ b/drivers/scsi/ufs/ufshpb.c
@@ -869,12 +869,6 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
struct ufshpb_region *rgn, *victim_rgn = NULL;
list_for_each_entry(rgn, &lru_info->lh_lru_rgn, list_lru_rgn) {
- if (!rgn) {
- dev_err(&hpb->sdev_ufs_lu->sdev_dev,
- "%s: no region allocated\n",
- __func__);
- return NULL;
- }
if (ufshpb_check_srgns_issue_state(hpb, rgn))
continue;
@@ -890,6 +884,11 @@ static struct ufshpb_region *ufshpb_victim_lru_info(struct ufshpb_lu *hpb)
break;
}
+ if (!victim_rgn)
+ dev_err(&hpb->sdev_ufs_lu->sdev_dev,
+ "%s: no region allocated\n",
+ __func__);
+
return victim_rgn;
}
base-commit: 14702b3b2438e2f2d07ae93b5d695c166e5c83d1
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH v2] ufs: fix an NULL check on list iterator
2022-03-20 15:07 ` [PATCH v2] ufs: fix an NULL check on list iterator Xiaomeng Tong
@ 2022-03-21 13:17 ` Daejun Park
0 siblings, 0 replies; 2+ messages in thread
From: Daejun Park @ 2022-03-21 13:17 UTC (permalink / raw)
To: Xiaomeng Tong, ALIM AKHTAR
Cc: avri.altman@wdc.com, jejb@linux.ibm.com,
martin.petersen@oracle.com, Daejun Park, beanhuo@micron.com,
bvanassche@acm.org, Keoseong Park, gregkh@linuxfoundation.org,
stanley.chu@mediatek.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, jakobkoschel@gmail.com
Hi Xiaomeng Tong,
>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.
>
>Fixes: 4b5f49079c52a ("scsi: ufs: ufshpb: L2P map management for HPB read")
>Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
>---
Good catch. Free to add my reviewed-by tag.
Reviewed-by: Daejun Park <daejun7.park@samsung.com>
Thanks,
Daejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-21 23:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20220320150754epcas2p3ffdbcd31ff5f4432e8d0a1106c91d729@epcms2p6>
2022-03-20 15:07 ` [PATCH v2] ufs: fix an NULL check on list iterator Xiaomeng Tong
2022-03-21 13:17 ` Daejun Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox