diff --git a/drivers/gpio/gpiolib-kunit.c b/drivers/gpio/gpiolib-kunit.c index e6cb43a8df5b..6a2c8b34f34b 100644 --- a/drivers/gpio/gpiolib-kunit.c +++ b/drivers/gpio/gpiolib-kunit.c @@ -28,6 +28,8 @@ #define GPIO_TEST_PROVIDER_NGPIO 4 +KUNIT_DEFINE_ACTION_WRAPPER(gpio_device_put_wrapper, gpio_device_put, struct gpio_device *); + /* * The test provider tracks per-line direction and value so that lines can be * driven as both inputs and outputs - this is needed to exercise input as well @@ -770,6 +772,7 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset, struct property_entry properties[2]; struct platform_device *pdev; struct fwnode_handle *fwnode; + struct gpio_device *gdev; struct gpio_desc *desc; bool bound = true; int ret; @@ -789,10 +792,12 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset, wait_for_device_probe(); /* The hog must have configured the line with the expected direction. */ - struct gpio_device *gdev __free(gpio_device_put) = - gpio_device_find_by_label(GPIO_CONSUMER_NAME); + gdev = gpio_device_find_by_label(GPIO_CONSUMER_NAME); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, gdev); + ret = kunit_add_action_or_reset(test, gpio_device_put_wrapper, gdev); + KUNIT_ASSERT_EQ(test, ret, 0); + desc = gpio_device_get_desc(gdev, offset); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, desc);