Skip to contentSkip to conversation

scsi: ufs: Fix unsigned int compared with less than zero

PATCH Applied Colin King 3 participants 4 messages Aug 6, 2021 – Aug 17, 2021

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 scsi: ufs: Fix unsigned int compared with less than zero

From: Colin Ian King <[email protected]>

Variable tag is currently and unsigned int and is being compared to less than zero, this check is always false. Fix this by making tag an int.

Addresses-Coverity: ("Macro compares unsigned to 0")

Fixes 4728ab4a8e64 ("scsi: ufs: Remove ufshcd_valid_tag()")
---
 drivers/scsi/ufs/ufshcd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +1 -1
index 47a5085f16a9..21378682cb4f 100644
@@ -6976,7 +6976,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
 {
 	struct Scsi_Host *host = cmd->device->host;
 	struct ufs_hba *hba = shost_priv(host);
-	unsigned int tag = cmd->request->tag;
+	int tag = cmd->request->tag;
 	struct ufshcd_lrb *lrbp = &hba->lrb[tag];
 	unsigned long flags;
 	int err = FAILED;
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Colin King

From: Colin Ian King <[email protected]>

Variable tag is currently and unsigned int and is being compared to less than zero, this check is always false. Fix this by making tag an int.

Addresses-Coverity: ("Macro compares unsigned to 0")

Fixes 4728ab4a8e64 ("scsi: ufs: Remove ufshcd_valid_tag()")
---
  drivers/scsi/ufs/ufshcd.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +0 -0
index 47a5085f16a9..21378682cb4f 100644

drivers/scsi/ufs/ufshcd.c static int ufshcd_abort(struct scsi_cmnd *cmd) · line 6982

Quoted 8 lines
drivers/scsi/ufs/ufshcd.c +1 -1
@@ -6976,7 +6976,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
  {
  	struct Scsi_Host *host = cmd->device->host;
  	struct ufs_hba *hba = shost_priv(host);
-	unsigned int tag = cmd->request->tag;
+	int tag = cmd->request->tag;
  	struct ufshcd_lrb *lrbp = &hba->lrb[tag];
  	unsigned long flags;
  	int err = FAILED;

Thanks!

Bart.

#2 lore raw
In reply to Colin King

Colin,

Quoted 3 lines

Variable tag is currently and unsigned int and is being compared to less than zero, this check is always false. Fix this by making tag an int.

Applied to 5.15/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to Colin King
Quoted 8 lines · Colin King

From: Colin Ian King <[email protected]>

Variable tag is currently and unsigned int and is being compared to less than zero, this check is always false. Fix this by making tag an int.

[...]

Applied to 5.15/scsi-queue, thanks!

[1/1] scsi: ufs: Fix unsigned int compared with less than zero

      https://git.kernel.org/mkp/scsi/c/a5402cdcc2a9
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering