@@ -549,7 +549,9 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
549
549
if ((le32_to_cpu (get_name_reply -> status ) == CT_OK )
550
550
&& (get_name_reply -> data [0 ] != '\0' )) {
551
551
char * sp = get_name_reply -> data ;
552
- sp [sizeof (((struct aac_get_name_resp * )NULL )-> data )] = '\0' ;
552
+ int data_size = FIELD_SIZEOF (struct aac_get_name_resp , data );
553
+
554
+ sp [data_size - 1 ] = '\0' ;
553
555
while (* sp == ' ' )
554
556
++ sp ;
555
557
if (* sp ) {
@@ -579,21 +581,25 @@ static void get_container_name_callback(void *context, struct fib * fibptr)
579
581
static int aac_get_container_name (struct scsi_cmnd * scsicmd )
580
582
{
581
583
int status ;
584
+ int data_size ;
582
585
struct aac_get_name * dinfo ;
583
586
struct fib * cmd_fibcontext ;
584
587
struct aac_dev * dev ;
585
588
586
589
dev = (struct aac_dev * )scsicmd -> device -> host -> hostdata ;
587
590
591
+ data_size = FIELD_SIZEOF (struct aac_get_name_resp , data );
592
+
588
593
cmd_fibcontext = aac_fib_alloc_tag (dev , scsicmd );
589
594
590
595
aac_fib_init (cmd_fibcontext );
591
596
dinfo = (struct aac_get_name * ) fib_data (cmd_fibcontext );
597
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
592
598
593
599
dinfo -> command = cpu_to_le32 (VM_ContainerConfig );
594
600
dinfo -> type = cpu_to_le32 (CT_READ_NAME );
595
601
dinfo -> cid = cpu_to_le32 (scmd_id (scsicmd ));
596
- dinfo -> count = cpu_to_le32 (sizeof ((( struct aac_get_name_resp * ) NULL ) -> data ) );
602
+ dinfo -> count = cpu_to_le32 (data_size - 1 );
597
603
598
604
status = aac_fib_send (ContainerCommand ,
599
605
cmd_fibcontext ,
@@ -606,10 +612,8 @@ static int aac_get_container_name(struct scsi_cmnd * scsicmd)
606
612
/*
607
613
* Check that the command queued to the controller
608
614
*/
609
- if (status == - EINPROGRESS ) {
610
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
615
+ if (status == - EINPROGRESS )
611
616
return 0 ;
612
- }
613
617
614
618
printk (KERN_WARNING "aac_get_container_name: aac_fib_send failed with status: %d.\n" , status );
615
619
aac_fib_complete (cmd_fibcontext );
@@ -720,6 +724,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
720
724
721
725
dinfo -> count = cpu_to_le32 (scmd_id (scsicmd ));
722
726
dinfo -> type = cpu_to_le32 (FT_FILESYS );
727
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
723
728
724
729
status = aac_fib_send (ContainerCommand ,
725
730
fibptr ,
@@ -731,9 +736,7 @@ static void _aac_probe_container1(void * context, struct fib * fibptr)
731
736
/*
732
737
* Check that the command queued to the controller
733
738
*/
734
- if (status == - EINPROGRESS )
735
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
736
- else if (status < 0 ) {
739
+ if (status < 0 && status != - EINPROGRESS ) {
737
740
/* Inherit results from VM_NameServe, if any */
738
741
dresp -> status = cpu_to_le32 (ST_OK );
739
742
_aac_probe_container2 (context , fibptr );
@@ -761,6 +764,7 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
761
764
dinfo -> count = cpu_to_le32 (scmd_id (scsicmd ));
762
765
dinfo -> type = cpu_to_le32 (FT_FILESYS );
763
766
scsicmd -> SCp .ptr = (char * )callback ;
767
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
764
768
765
769
status = aac_fib_send (ContainerCommand ,
766
770
fibptr ,
@@ -772,10 +776,9 @@ static int _aac_probe_container(struct scsi_cmnd * scsicmd, int (*callback)(stru
772
776
/*
773
777
* Check that the command queued to the controller
774
778
*/
775
- if (status == - EINPROGRESS ) {
776
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
779
+ if (status == - EINPROGRESS )
777
780
return 0 ;
778
- }
781
+
779
782
if (status < 0 ) {
780
783
scsicmd -> SCp .ptr = NULL ;
781
784
aac_fib_complete (fibptr );
@@ -1121,6 +1124,7 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
1121
1124
dinfo -> command = cpu_to_le32 (VM_ContainerConfig );
1122
1125
dinfo -> type = cpu_to_le32 (CT_CID_TO_32BITS_UID );
1123
1126
dinfo -> cid = cpu_to_le32 (scmd_id (scsicmd ));
1127
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
1124
1128
1125
1129
status = aac_fib_send (ContainerCommand ,
1126
1130
cmd_fibcontext ,
@@ -1133,10 +1137,8 @@ static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
1133
1137
/*
1134
1138
* Check that the command queued to the controller
1135
1139
*/
1136
- if (status == - EINPROGRESS ) {
1137
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
1140
+ if (status == - EINPROGRESS )
1138
1141
return 0 ;
1139
- }
1140
1142
1141
1143
printk (KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n" , status );
1142
1144
aac_fib_complete (cmd_fibcontext );
@@ -2330,16 +2332,14 @@ static int aac_read(struct scsi_cmnd * scsicmd)
2330
2332
* Alocate and initialize a Fib
2331
2333
*/
2332
2334
cmd_fibcontext = aac_fib_alloc_tag (dev , scsicmd );
2333
-
2335
+ scsicmd -> SCp . phase = AAC_OWNER_FIRMWARE ;
2334
2336
status = aac_adapter_read (cmd_fibcontext , scsicmd , lba , count );
2335
2337
2336
2338
/*
2337
2339
* Check that the command queued to the controller
2338
2340
*/
2339
- if (status == - EINPROGRESS ) {
2340
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2341
+ if (status == - EINPROGRESS )
2341
2342
return 0 ;
2342
- }
2343
2343
2344
2344
printk (KERN_WARNING "aac_read: aac_fib_send failed with status: %d.\n" , status );
2345
2345
/*
@@ -2424,16 +2424,14 @@ static int aac_write(struct scsi_cmnd * scsicmd)
2424
2424
* Allocate and initialize a Fib then setup a BlockWrite command
2425
2425
*/
2426
2426
cmd_fibcontext = aac_fib_alloc_tag (dev , scsicmd );
2427
-
2427
+ scsicmd -> SCp . phase = AAC_OWNER_FIRMWARE ;
2428
2428
status = aac_adapter_write (cmd_fibcontext , scsicmd , lba , count , fua );
2429
2429
2430
2430
/*
2431
2431
* Check that the command queued to the controller
2432
2432
*/
2433
- if (status == - EINPROGRESS ) {
2434
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2433
+ if (status == - EINPROGRESS )
2435
2434
return 0 ;
2436
- }
2437
2435
2438
2436
printk (KERN_WARNING "aac_write: aac_fib_send failed with status: %d\n" , status );
2439
2437
/*
@@ -2583,6 +2581,7 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
2583
2581
synchronizecmd -> cid = cpu_to_le32 (scmd_id (scsicmd ));
2584
2582
synchronizecmd -> count =
2585
2583
cpu_to_le32 (sizeof (((struct aac_synchronize_reply * )NULL )-> data ));
2584
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2586
2585
2587
2586
/*
2588
2587
* Now send the Fib to the adapter
@@ -2598,10 +2597,8 @@ static int aac_synchronize(struct scsi_cmnd *scsicmd)
2598
2597
/*
2599
2598
* Check that the command queued to the controller
2600
2599
*/
2601
- if (status == - EINPROGRESS ) {
2602
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2600
+ if (status == - EINPROGRESS )
2603
2601
return 0 ;
2604
- }
2605
2602
2606
2603
printk (KERN_WARNING
2607
2604
"aac_synchronize: aac_fib_send failed with status: %d.\n" , status );
@@ -2661,6 +2658,7 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
2661
2658
pmcmd -> cid = cpu_to_le32 (sdev_id (sdev ));
2662
2659
pmcmd -> parm = (scsicmd -> cmnd [1 ] & 1 ) ?
2663
2660
cpu_to_le32 (CT_PM_UNIT_IMMEDIATE ) : 0 ;
2661
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2664
2662
2665
2663
/*
2666
2664
* Now send the Fib to the adapter
@@ -2676,10 +2674,8 @@ static int aac_start_stop(struct scsi_cmnd *scsicmd)
2676
2674
/*
2677
2675
* Check that the command queued to the controller
2678
2676
*/
2679
- if (status == - EINPROGRESS ) {
2680
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
2677
+ if (status == - EINPROGRESS )
2681
2678
return 0 ;
2682
- }
2683
2679
2684
2680
aac_fib_complete (cmd_fibcontext );
2685
2681
aac_fib_free (cmd_fibcontext );
@@ -3198,10 +3194,11 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
3198
3194
return - EBUSY ;
3199
3195
if (copy_from_user (& qd , arg , sizeof (struct aac_query_disk )))
3200
3196
return - EFAULT ;
3201
- if (qd .cnum == -1 )
3197
+ if (qd .cnum == -1 ) {
3198
+ if (qd .id < 0 || qd .id >= dev -> maximum_num_containers )
3199
+ return - EINVAL ;
3202
3200
qd .cnum = qd .id ;
3203
- else if ((qd .bus == -1 ) && (qd .id == -1 ) && (qd .lun == -1 ))
3204
- {
3201
+ } else if ((qd .bus == -1 ) && (qd .id == -1 ) && (qd .lun == -1 )) {
3205
3202
if (qd .cnum < 0 || qd .cnum >= dev -> maximum_num_containers )
3206
3203
return - EINVAL ;
3207
3204
qd .instance = dev -> scsi_host_ptr -> host_no ;
@@ -3686,16 +3683,14 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
3686
3683
* Allocate and initialize a Fib then setup a BlockWrite command
3687
3684
*/
3688
3685
cmd_fibcontext = aac_fib_alloc_tag (dev , scsicmd );
3689
-
3686
+ scsicmd -> SCp . phase = AAC_OWNER_FIRMWARE ;
3690
3687
status = aac_adapter_scsi (cmd_fibcontext , scsicmd );
3691
3688
3692
3689
/*
3693
3690
* Check that the command queued to the controller
3694
3691
*/
3695
- if (status == - EINPROGRESS ) {
3696
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
3692
+ if (status == - EINPROGRESS )
3697
3693
return 0 ;
3698
- }
3699
3694
3700
3695
printk (KERN_WARNING "aac_srb: aac_fib_send failed with status: %d\n" , status );
3701
3696
aac_fib_complete (cmd_fibcontext );
@@ -3733,15 +3728,14 @@ static int aac_send_hba_fib(struct scsi_cmnd *scsicmd)
3733
3728
if (!cmd_fibcontext )
3734
3729
return -1 ;
3735
3730
3731
+ scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
3736
3732
status = aac_adapter_hba (cmd_fibcontext , scsicmd );
3737
3733
3738
3734
/*
3739
3735
* Check that the command queued to the controller
3740
3736
*/
3741
- if (status == - EINPROGRESS ) {
3742
- scsicmd -> SCp .phase = AAC_OWNER_FIRMWARE ;
3737
+ if (status == - EINPROGRESS )
3743
3738
return 0 ;
3744
- }
3745
3739
3746
3740
pr_warn ("aac_hba_cmd_req: aac_fib_send failed with status: %d\n" ,
3747
3741
status );
0 commit comments