@@ -2703,22 +2703,22 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
2703
2703
ap = arr + offset ;
2704
2704
}
2705
2705
2706
- if ((subpcode > 0x0 ) && (subpcode < 0xff ) && (0x19 != pcode )) {
2707
- /* TODO: Control Extension page */
2708
- mk_sense_invalid_fld (scp , SDEB_IN_CDB , 3 , -1 );
2709
- return check_condition_result ;
2710
- }
2711
-
2712
2706
switch (pcode ) {
2713
2707
case 0x1 : /* Read-Write error recovery page, direct access */
2708
+ if (subpcode > 0x0 && subpcode < 0xff )
2709
+ goto bad_subpcode ;
2714
2710
len = resp_err_recov_pg (ap , pcontrol , target );
2715
2711
offset += len ;
2716
2712
break ;
2717
2713
case 0x2 : /* Disconnect-Reconnect page, all devices */
2714
+ if (subpcode > 0x0 && subpcode < 0xff )
2715
+ goto bad_subpcode ;
2718
2716
len = resp_disconnect_pg (ap , pcontrol , target );
2719
2717
offset += len ;
2720
2718
break ;
2721
2719
case 0x3 : /* Format device page, direct access */
2720
+ if (subpcode > 0x0 && subpcode < 0xff )
2721
+ goto bad_subpcode ;
2722
2722
if (is_disk ) {
2723
2723
len = resp_format_pg (ap , pcontrol , target );
2724
2724
offset += len ;
@@ -2727,6 +2727,8 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
2727
2727
}
2728
2728
break ;
2729
2729
case 0x8 : /* Caching page, direct access */
2730
+ if (subpcode > 0x0 && subpcode < 0xff )
2731
+ goto bad_subpcode ;
2730
2732
if (is_disk || is_zbc ) {
2731
2733
len = resp_caching_pg (ap , pcontrol , target );
2732
2734
offset += len ;
@@ -2735,14 +2737,14 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
2735
2737
}
2736
2738
break ;
2737
2739
case 0xa : /* Control Mode page, all devices */
2740
+ if (subpcode > 0x0 && subpcode < 0xff )
2741
+ goto bad_subpcode ;
2738
2742
len = resp_ctrl_m_pg (ap , pcontrol , target );
2739
2743
offset += len ;
2740
2744
break ;
2741
2745
case 0x19 : /* if spc==1 then sas phy, control+discover */
2742
- if ((subpcode > 0x2 ) && (subpcode < 0xff )) {
2743
- mk_sense_invalid_fld (scp , SDEB_IN_CDB , 3 , -1 );
2744
- return check_condition_result ;
2745
- }
2746
+ if (subpcode > 0x2 && subpcode < 0xff )
2747
+ goto bad_subpcode ;
2746
2748
len = 0 ;
2747
2749
if ((0x0 == subpcode ) || (0xff == subpcode ))
2748
2750
len += resp_sas_sf_m_pg (ap + len , pcontrol , target );
@@ -2754,35 +2756,31 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
2754
2756
offset += len ;
2755
2757
break ;
2756
2758
case 0x1c : /* Informational Exceptions Mode page, all devices */
2759
+ if (subpcode > 0x0 && subpcode < 0xff )
2760
+ goto bad_subpcode ;
2757
2761
len = resp_iec_m_pg (ap , pcontrol , target );
2758
2762
offset += len ;
2759
2763
break ;
2760
2764
case 0x3f : /* Read all Mode pages */
2761
- if ((0 == subpcode ) || (0xff == subpcode )) {
2762
- len = resp_err_recov_pg (ap , pcontrol , target );
2763
- len += resp_disconnect_pg (ap + len , pcontrol , target );
2764
- if (is_disk ) {
2765
- len += resp_format_pg (ap + len , pcontrol ,
2766
- target );
2767
- len += resp_caching_pg (ap + len , pcontrol ,
2768
- target );
2769
- } else if (is_zbc ) {
2770
- len += resp_caching_pg (ap + len , pcontrol ,
2771
- target );
2772
- }
2773
- len += resp_ctrl_m_pg (ap + len , pcontrol , target );
2774
- len += resp_sas_sf_m_pg (ap + len , pcontrol , target );
2775
- if (0xff == subpcode ) {
2776
- len += resp_sas_pcd_m_spg (ap + len , pcontrol ,
2777
- target , target_dev_id );
2778
- len += resp_sas_sha_m_spg (ap + len , pcontrol );
2779
- }
2780
- len += resp_iec_m_pg (ap + len , pcontrol , target );
2781
- offset += len ;
2782
- } else {
2783
- mk_sense_invalid_fld (scp , SDEB_IN_CDB , 3 , -1 );
2784
- return check_condition_result ;
2765
+ if (subpcode > 0x0 && subpcode < 0xff )
2766
+ goto bad_subpcode ;
2767
+ len = resp_err_recov_pg (ap , pcontrol , target );
2768
+ len += resp_disconnect_pg (ap + len , pcontrol , target );
2769
+ if (is_disk ) {
2770
+ len += resp_format_pg (ap + len , pcontrol , target );
2771
+ len += resp_caching_pg (ap + len , pcontrol , target );
2772
+ } else if (is_zbc ) {
2773
+ len += resp_caching_pg (ap + len , pcontrol , target );
2774
+ }
2775
+ len += resp_ctrl_m_pg (ap + len , pcontrol , target );
2776
+ len += resp_sas_sf_m_pg (ap + len , pcontrol , target );
2777
+ if (0xff == subpcode ) {
2778
+ len += resp_sas_pcd_m_spg (ap + len , pcontrol , target ,
2779
+ target_dev_id );
2780
+ len += resp_sas_sha_m_spg (ap + len , pcontrol );
2785
2781
}
2782
+ len += resp_iec_m_pg (ap + len , pcontrol , target );
2783
+ offset += len ;
2786
2784
break ;
2787
2785
default :
2788
2786
goto bad_pcode ;
@@ -2796,6 +2794,10 @@ static int resp_mode_sense(struct scsi_cmnd *scp,
2796
2794
bad_pcode :
2797
2795
mk_sense_invalid_fld (scp , SDEB_IN_CDB , 2 , 5 );
2798
2796
return check_condition_result ;
2797
+
2798
+ bad_subpcode :
2799
+ mk_sense_invalid_fld (scp , SDEB_IN_CDB , 3 , -1 );
2800
+ return check_condition_result ;
2799
2801
}
2800
2802
2801
2803
#define SDEBUG_MAX_MSELECT_SZ 512
0 commit comments