gpio: sim: initialize a managed pointer when declaring it
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Sun, 17 Sep 2023 08:58:37 +0000 (10:58 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 25 Sep 2023 06:41:07 +0000 (08:41 +0200)
Variables managed with __free() should typically be initialized where
they are declared so that the __free() callback is paired with its
counterpart resource allocator. Fix the second instance of using
__free() in gpio-sim to follow this pattern.

Fixes: 3faf89f27aab ("gpio: sim: simplify code with cleanup helpers")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-sim.c

index 59cba5b5f54a995aeae06a8c131216ce45fc8796..460389bb8e3f1481a6ca9e44895bae894d3e4871 100644 (file)
@@ -1485,10 +1485,10 @@ static const struct config_item_type gpio_sim_device_config_group_type = {
 static struct config_group *
 gpio_sim_config_make_device_group(struct config_group *group, const char *name)
 {
-       struct gpio_sim_device *dev __free(kfree) = NULL;
        int id;
 
-       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+       struct gpio_sim_device *dev __free(kfree) = kzalloc(sizeof(*dev),
+                                                           GFP_KERNEL);
        if (!dev)
                return ERR_PTR(-ENOMEM);