diff --git a/internal/tcmu/commands.go b/internal/tcmu/commands.go index ee17d0b..19b69d1 100644 --- a/internal/tcmu/commands.go +++ b/internal/tcmu/commands.go @@ -52,14 +52,14 @@ func (h *torusHandler) handleWrite(cmd *tcmu.SCSICmd) (tcmu.SCSIResponse, error) cmd.Buf = make([]byte, length) } n, err := cmd.Read(cmd.Buf[:int(length)]) - if n < length { - clog.Error("write/read failed: unable to copy enough") - return cmd.MediumError(), nil - } if err != nil { clog.Errorf("write/read failed: error: %v", err) return cmd.MediumError(), nil } + if n < length { + clog.Error("write/read failed: unable to copy enough") + return cmd.MediumError(), nil + } n, err = h.file.WriteAt(cmd.Buf[:length], int64(offset)) if n < length { clog.Error("write/write failed: unable to copy enough")