of: unittest: Fix compile in the non-dynamic case
authorChristian A. Ehrhardt <lk@c--e.de>
Mon, 29 Jan 2024 19:25:56 +0000 (20:25 +0100)
committerRob Herring <robh@kernel.org>
Wed, 31 Jan 2024 22:04:18 +0000 (16:04 -0600)
commit607aad1e4356c210dbef9022955a3089377909b2
tree6e360cc0a6919530d61dc91015ecf8ed58b68d4b
parent8f7e917907385e112a845d668ae2832f41e64bf5
of: unittest: Fix compile in the non-dynamic case

If CONFIG_OF_KOBJ is not set, a device_node does not contain a
kobj and attempts to access the embedded kobj via kref_read break
the compile.

Replace affected kref_read calls with a macro that reads the
refcount if it exists and returns 1 if there is no embedded kobj.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202401291740.VP219WIz-lkp@intel.com/
Fixes: 4dde83569832 ("of: Fix double free in of_parse_phandle_with_args_map")
Signed-off-by: Christian A. Ehrhardt <lk@c--e.de>
Link: https://lore.kernel.org/r/20240129192556.403271-1-lk@c--e.de
Signed-off-by: Rob Herring <robh@kernel.org>
drivers/of/unittest.c