Skip to content

Commit d5d92b6

Browse files
Daejun7Parkmartinkpetersen
authored andcommitted
scsi: ufs: core: Fix referencing invalid rsp field
Fix referencing sense data when it is invalid. When the length of the data segment is 0, there is no valid information in the rsp field, so ufshpb_rsp_upiu() is returned without additional operation. Link: https://lore.kernel.org/r/252651381.41652940482659.JavaMail.epsvc@epcpadp4 Fixes: 4b5f490 ("scsi: ufs: ufshpb: L2P map management for HPB read") Acked-by: Avri Altman <[email protected]> Signed-off-by: Daejun Park <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 525f447 commit d5d92b6

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

drivers/scsi/ufs/ufshpb.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,13 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
12541254
struct utp_hpb_rsp *rsp_field = &lrbp->ucd_rsp_ptr->hr;
12551255
int data_seg_len;
12561256

1257+
data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
1258+
& MASK_RSP_UPIU_DATA_SEG_LEN;
1259+
1260+
/* If data segment length is zero, rsp_field is not valid */
1261+
if (!data_seg_len)
1262+
return;
1263+
12571264
if (unlikely(lrbp->lun != rsp_field->lun)) {
12581265
struct scsi_device *sdev;
12591266
bool found = false;
@@ -1288,18 +1295,6 @@ void ufshpb_rsp_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
12881295
return;
12891296
}
12901297

1291-
data_seg_len = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_2)
1292-
& MASK_RSP_UPIU_DATA_SEG_LEN;
1293-
1294-
/* To flush remained rsp_list, we queue the map_work task */
1295-
if (!data_seg_len) {
1296-
if (!ufshpb_is_general_lun(hpb->lun))
1297-
return;
1298-
1299-
ufshpb_kick_map_work(hpb);
1300-
return;
1301-
}
1302-
13031298
BUILD_BUG_ON(sizeof(struct utp_hpb_rsp) != UTP_HPB_RSP_SIZE);
13041299

13051300
if (!ufshpb_is_hpb_rsp_valid(hba, lrbp, rsp_field))

0 commit comments

Comments
 (0)