]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: NCR5380: Initialize buffer for MSG IN and STATUS transfers
authorFinn Thain <fthain@linux-m68k.org>
Wed, 7 Aug 2024 03:36:28 +0000 (13:36 +1000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 13 Aug 2024 02:05:49 +0000 (22:05 -0400)
Following an incomplete transfer in MSG IN phase, the driver would not
notice the problem and would make use of invalid data. Initialize 'tmp'
appropriately and bail out if no message was received. For STATUS phase,
preserve the existing status code unless a new value was transferred.

Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@linux-m68k.org>
Link: https://lore.kernel.org/r/52e02a8812ae1a2d810d7f9f7fd800c3ccc320c4.1723001788.git.fthain@linux-m68k.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/NCR5380.c

index 00e245173320c30cdfc42e6392e943f7a1459726..4fcb73b727aa5d850346336e64e4405547dc60e1 100644 (file)
@@ -1807,8 +1807,11 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
                                return;
                        case PHASE_MSGIN:
                                len = 1;
+                               tmp = 0xff;
                                data = &tmp;
                                NCR5380_transfer_pio(instance, &phase, &len, &data, 0);
+                               if (tmp == 0xff)
+                                       break;
                                ncmd->message = tmp;
 
                                switch (tmp) {
@@ -1996,6 +1999,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
                                break;
                        case PHASE_STATIN:
                                len = 1;
+                               tmp = ncmd->status;
                                data = &tmp;
                                NCR5380_transfer_pio(instance, &phase, &len, &data, 0);
                                ncmd->status = tmp;