Skip to contentSkip to conversation

scsi: scsi_debug: fix uninitialized variable use

PATCH Superseded Arnd Bergmann 3 participants 3 messages Feb 25, 2025 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: scsi_debug: fix uninitialized variable use

From: Arnd Bergmann <[email protected]>

It appears that a typo has made it into the newly added code

drivers/scsi/scsi_debug.c:3035:3: error: variable 'len' is uninitialized when used here [-Werror,-Wuninitialized]

 3035 |                 len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
      |                 ^~~

Replace the '+=' with the intended '=' here.

Fixes e7795366c41d ("scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes")
---
 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
index 722ee8c067ae..f3e9a63bbf02 100644
@@ -3032,7 +3032,7 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
 	case 0xf:	/* Compression Mode Page (tape) */
 		if (!is_tape)
 			goto bad_pcode;
-		len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
+		len = resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
 		offset += len;
 		break;
 	case 0x11:	/* Partition Mode Page (tape) */
Signature · 1 line
2.39.5
Acked-by Kai Mäkisara on v1 1/1
#1 lore raw
Quoted 12 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

It appears that a typo has made it into the newly added code

drivers/scsi/scsi_debug.c:3035:3: error: variable 'len' is uninitialized when used here [-Werror,-Wuninitialized]

3035 |                 len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
     |                 ^~~

Replace the '+=' with the intended '=' here.

One more of these ;) The fix is correct. (And now I checked with grep that v2 does not have any more of these.)

Quoted 2 lines
Fixes e7795366c41d ("scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes")

The bug was actually in 568354b24c7d "scsi: scsi_debug: Add compression mode page for tapes"

Quoted 1 line
Acked-by Kai Mäkisara <[email protected] <mailto:[email protected]>>
Quoted 9 lines

---
drivers/scsi/scsi_debug.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +0 -0
index 722ee8c067ae..f3e9a63bbf02 100644
@@ -3032,7 +3032,7 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
Quoted 12 lines

case 0xf: /* Compression Mode Page (tape) */
if (!is_tape)
goto bad_pcode;
- len += resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce);
+ len = resp_compression_m_pg(ap, pcontrol, target, devip->tape_dce); offset += len;
break;
case 0x11: /* Partition Mode Page (tape) */

Signature · 1 line
2.39.5

Thanks,
Kai

#2 lore raw
Quoted 6 lines · Kai Mäkisara (Kolumbus)
Quoted 3 lines · Arnd Bergmann
Fixes e7795366c41d ("scsi: scsi_debug: Add READ BLOCK LIMITS and modify LOAD for tapes")

The bug was actually in 568354b24c7d "scsi: scsi_debug: Add compression mode page for tapes"

Ah indeed, my mistake. At least I got the right author.

Quoted 4 lines
Quoted 1 line

<mailto:[email protected]>>

Thanks!

I'll resend with the correct fixes tag

Arnd