@@ -1207,14 +1207,6 @@ impl RequestHandler for AdminCommandRequestHeader {
12071207 return Err ( ResponseStatus :: InternalError ) ;
12081208 }
12091209
1210- if ctx. ctlid > 0 {
1211- if subsys. ctlrs . len ( ) > 1 {
1212- todo ! ( "Support for selecting controllers via CTLID" ) ;
1213- }
1214- debug ! ( "Invalid CTLID: {}" , ctx. ctlid) ;
1215- return Err ( ResponseStatus :: InvalidParameter ) ;
1216- }
1217-
12181210 match & self . op {
12191211 AdminCommandRequestType :: Identify ( identify) => {
12201212 identify. handle ( ctx, mep, subsys, rest, resp) . await
@@ -1387,10 +1379,10 @@ impl RequestHandler for AdminIdentifyRequest {
13871379 . await
13881380 }
13891381 AdminIdentifyCnsRequestType :: IdentifyController => {
1390- let ctlr = subsys
1391- . ctlrs
1392- . first ( )
1393- . expect ( "Device needs at least one controller" ) ;
1382+ let Some ( ctlr) = subsys. ctlrs . get ( ctx . ctlid as usize ) else {
1383+ debug ! ( "No such CTLID: {}" , ctx . ctlid ) ;
1384+ return Err ( ResponseStatus :: InvalidParameter ) ;
1385+ } ;
13941386
13951387 let aicr = AdminIdentifyControllerResponse {
13961388 vid : subsys. info . pci_vid ,
@@ -1576,10 +1568,10 @@ impl RequestHandler for AdminIdentifyRequest {
15761568 . await
15771569 }
15781570 AdminIdentifyCnsRequestType :: SecondaryControllerList => {
1579- let ctlr = subsys
1580- . ctlrs
1581- . first ( )
1582- . expect ( "Device needs at least one controller" ) ;
1571+ let Some ( ctlr) = subsys. ctlrs . get ( ctx . ctlid as usize ) else {
1572+ debug ! ( "No such CTLID: {}" , ctx . ctlid ) ;
1573+ return Err ( ResponseStatus :: InvalidParameter ) ;
1574+ } ;
15831575
15841576 if !ctlr. secondaries . is_empty ( ) {
15851577 todo ! ( "Support listing secondary controllers" ) ;
0 commit comments