fix: handle discovery sessions in UnBindISCSISession
Discovery sessions have nil Target and nil ITNexus. The cleanup path crashed with nil pointer dereference when trying to remove ITNexus or access Target.Sessions for discovery sessions. Guard against nil Target (just release TSIH) and nil ITNexus. Also add nil safety to clearHostIP helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -376,12 +376,19 @@ func (s *ISCSITargetDriver) handler(events byte, conn *iscsiConnection) {
|
||||
}
|
||||
|
||||
func (s *ISCSITargetDriver) clearHostIP(conn *iscsiConnection) {
|
||||
if conn.conn == nil {
|
||||
return
|
||||
}
|
||||
IPMutex.Lock()
|
||||
remoteIP := strings.Split(conn.conn.RemoteAddr().String(), ":")[0]
|
||||
defer IPMutex.Unlock()
|
||||
addr := conn.conn.RemoteAddr()
|
||||
if addr == nil {
|
||||
return
|
||||
}
|
||||
remoteIP := strings.Split(addr.String(), ":")[0]
|
||||
if CurrentHostIP == remoteIP {
|
||||
CurrentHostIP = ""
|
||||
}
|
||||
IPMutex.Unlock()
|
||||
}
|
||||
|
||||
func (s *ISCSITargetDriver) rxHandler(conn *iscsiConnection) {
|
||||
|
||||
Reference in New Issue
Block a user