From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Kent Gibson <warthog618@gmail.com>,
Alexey Dobriyan <adobriyan@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
akpm@linux-foundation.org
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: [PATCH v3 2/2] gpio: sim: initialize a managed pointer when declaring it
Date: Sun, 17 Sep 2023 11:12:25 +0200 [thread overview]
Message-ID: <20230917091225.6350-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20230917091225.6350-1-brgl@bgdev.pl>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index 7d52f7caa1c7..1a8a332a803b 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -1481,10 +1481,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);
--
2.39.2
next prev parent reply other threads:[~2023-09-17 9:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-17 9:12 [PATCH v3 0/2] gpio: sim: improve the usage of __free() Bartosz Golaszewski
2023-09-17 9:12 ` [PATCH v3 1/2] gpio: sim: fix an invalid __free() usage Bartosz Golaszewski
2023-09-17 16:46 ` Linus Torvalds
2023-09-17 18:59 ` Bartosz Golaszewski
2023-09-17 9:12 ` Bartosz Golaszewski [this message]
2023-09-18 7:06 ` [PATCH v3 2/2] gpio: sim: initialize a managed pointer when declaring it Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230917091225.6350-3-brgl@bgdev.pl \
--to=brgl@bgdev.pl \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.