Subject: Re: [PATCH] mpls: refactor mpls_dev_notify() to use guard(mutex)

From: Jakub Kicinski <[email-masked]>
Date: Tue, 2 Jun 2026 12:03:35 -0700

On Mon,  1 Jun 2026 11:38:23 -0300 Caio Morais wrote:
> Replace explicit mutex_lock() and mutex_unlock() calls with the
> guard(mutex) auto-cleanup helper from <linux/cleanup.h>. 

Quoting documentation:

  Using device-managed and cleanup.h constructs
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  Netdev remains skeptical about promises of all "auto-cleanup" APIs,
  including even ``devm_`` helpers, historically. They are not the preferred
  style of implementation, merely an acceptable one.
  
  Use of ``guard()`` is discouraged within any function longer than 20 lines,
  ``scoped_guard()`` is considered more readable. Using normal lock/unlock is
  still (weakly) preferred.
  
  Low level cleanup constructs (such as ``__free()``) can be used when building
  APIs and helpers, especially scoped iterators. However, direct use of
  ``__free()`` within networking core and drivers is discouraged.
  Similar guidance applies to declaring variables mid-function.
  
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

In general please don't send us arbitrary code cleanup patches
if you're not actively working on real changes to the code.
-- 
pw-bot: reject