dgryski.semgrep-go.wronglock.wrong-lock-unlock

profile photo of dgryskidgryski
Author
581
Download Count*
License

Wrong lock/unlock pair?

Run Locally

Run in CI

Defintion

rules:
  - id: wrong-lock-unlock
    patterns:
      - pattern-either:
          - pattern: |
              $M.Lock()
              defer $M.RUnlock()
          - pattern: |
              $M.RLock()
              defer $M.Unlock()
          - pattern: |
              $M.Lock()
              defer $M.Lock()
          - pattern: |
              $M.RLock()
              defer $M.RLock()
    message: Wrong lock/unlock pair?
    languages:
      - go
    severity: ERROR
    metadata:
      license: MIT