]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
device property: Make modifications of fwnode "flags" thread safe
authorDouglas Anderson <dianders@chromium.org>
Tue, 17 Mar 2026 16:01:20 +0000 (09:01 -0700)
committerDanilo Krummrich <dakr@kernel.org>
Thu, 26 Mar 2026 21:00:59 +0000 (22:00 +0100)
commitf72e77c33e4b5657af35125e75bab249256030f3
tree63beeaff19d14efcb3485bfccc419a610fdf2d70
parent14cf406e083c0541e40cd467ae8336ecceede09e
device property: Make modifications of fwnode "flags" thread safe

In various places in the kernel, we modify the fwnode "flags" member
by doing either:
  fwnode->flags |= SOME_FLAG;
  fwnode->flags &= ~SOME_FLAG;

This type of modification is not thread-safe. If two threads are both
mucking with the flags at the same time then one can clobber the
other.

While flags are often modified while under the "fwnode_link_lock",
this is not universally true.

Create some accessor functions for setting, clearing, and testing the
FWNODE flags and move all users to these accessor functions. New
accessor functions use set_bit() and clear_bit(), which are
thread-safe.

Cc: stable@vger.kernel.org
Fixes: c2c724c868c4 ("driver core: Add fw_devlink_parse_fwtree()")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Saravana Kannan <saravanak@kernel.org>
Link: https://patch.msgid.link/20260317090112.v2.1.I0a4d03104ecd5103df3d76f66c8d21b1d15a2e38@changeid
[ Fix fwnode_clear_flag() argument alignment, restore dropped blank
  line in fwnode_dev_initialized(), and remove unnecessary parentheses
  around fwnode_test_flag() calls. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/base/core.c
drivers/bus/imx-weim.c
drivers/i2c/i2c-core-of.c
drivers/net/phy/mdio_bus_provider.c
drivers/of/base.c
drivers/of/dynamic.c
drivers/of/platform.c
drivers/spi/spi.c
include/linux/fwnode.h