All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: scsi_debug: fix uninitialized variable use
@ 2025-02-25  8:56 Arnd Bergmann
  2025-02-25  9:43 ` "Kai Mäkisara (Kolumbus)"
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2025-02-25  8:56 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen, Kai Mäkisara,
	John Meneghini
  Cc: Arnd Bergmann, Bart Van Assche, John Garry, linux-scsi,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/scsi_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 722ee8c067ae..f3e9a63bbf02 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -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) */
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: scsi_debug: fix uninitialized variable use
  2025-02-25  8:56 [PATCH] scsi: scsi_debug: fix uninitialized variable use Arnd Bergmann
@ 2025-02-25  9:43 ` "Kai Mäkisara (Kolumbus)"
  2025-02-25  9:55   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: "Kai Mäkisara (Kolumbus)" @ 2025-02-25  9:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James E.J. Bottomley, Martin K. Petersen, John Meneghini,
	Arnd Bergmann, Bart Van Assche, John Garry, linux-scsi,
	linux-kernel


> On 25. Feb 2025, at 10.56, Arnd Bergmann <arnd@kernel.org> wrote:
> 
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.)

> 
> 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"

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi <mailto:kai.makisara@kolumbus.fi>>

> ---
> drivers/scsi/scsi_debug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 722ee8c067ae..f3e9a63bbf02 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -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) */
> -- 
> 2.39.5
> 
> 

Thanks,
Kai


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: scsi_debug: fix uninitialized variable use
  2025-02-25  9:43 ` "Kai Mäkisara (Kolumbus)"
@ 2025-02-25  9:55   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-02-25  9:55 UTC (permalink / raw)
  To: "Kai Mäkisara (Kolumbus)", Arnd Bergmann
  Cc: James E . J . Bottomley, Martin K. Petersen, John Meneghini,
	Bart Van Assche, John Garry, linux-scsi, linux-kernel

On Tue, Feb 25, 2025, at 10:43, "Kai Mäkisara (Kolumbus)" wrote:
>> On 25. Feb 2025, at 10.56, Arnd Bergmann <arnd@kernel.org> wrote:
>> 
>> 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.

>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Acked-by: Kai Mäkisara <kai.makisara@kolumbus.fi 
> <mailto:kai.makisara@kolumbus.fi>>

Thanks!

I'll resend with the correct fixes tag

      Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-25  9:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-25  8:56 [PATCH] scsi: scsi_debug: fix uninitialized variable use Arnd Bergmann
2025-02-25  9:43 ` "Kai Mäkisara (Kolumbus)"
2025-02-25  9:55   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.