From: Yury Norov <yury.norov@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH 4/4] genirq/irq_sim: shrink code by using cleanup helpers
Date: Sun, 13 Aug 2023 18:09:12 -0700 [thread overview]
Message-ID: <ZNl+uKweuqJKaMcb@yury-ThinkPad> (raw)
In-Reply-To: <20230812194457.6432-5-brgl@bgdev.pl>
On Sat, Aug 12, 2023 at 09:44:57PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Use the new __free helper from linux/cleanup.h to remove all gotos and
> simplify the error paths.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> kernel/irq/irq_sim.c | 24 ++++++++++--------------
> 1 file changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c
> index a8b013d0c5be..202beb1169c9 100644
> --- a/kernel/irq/irq_sim.c
> +++ b/kernel/irq/irq_sim.c
> @@ -4,6 +4,7 @@
> * Copyright (C) 2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>
> */
>
> +#include <linux/cleanup.h>
> #include <linux/interrupt.h>
> #include <linux/irq.h>
> #include <linux/irq_sim.h>
> @@ -170,34 +171,29 @@ static const struct irq_domain_ops irq_sim_domain_ops = {
> struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode,
> unsigned int num_irqs)
> {
> - struct irq_sim_work_ctx *work_ctx;
> + struct irq_sim_work_ctx *work_ctx __free(kfree) = NULL;
> + unsigned long *pending __free(bitmap) = NULL;
Why initializing here as NULL ...
> work_ctx = kmalloc(sizeof(*work_ctx), GFP_KERNEL);
> if (!work_ctx)
> - goto err_out;
> + return ERR_PTR(-ENOMEM);
>
> - work_ctx->pending = bitmap_zalloc(num_irqs, GFP_KERNEL);
> - if (!work_ctx->pending)
> - goto err_free_work_ctx;
> + pending = bitmap_zalloc(num_irqs, GFP_KERNEL);
> + if (!pending)
> + return ERR_PTR(-ENOMEM);
and overriding immediately after that? Not familiar to __free()
machinery in details, although. Does it require initialization?
Thank,
Yury
next prev parent reply other threads:[~2023-08-14 1:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-12 19:44 [PATCH 0/4] genirq/irq_sim: fix a use-after-free bug + some Bartosz Golaszewski
2023-08-12 19:44 ` [PATCH 1/4] genirq/irq_sim: dispose of remaining mappings before removing the domain Bartosz Golaszewski
2023-08-15 10:38 ` Andy Shevchenko
2023-08-15 16:09 ` Yury Norov
2023-08-15 16:53 ` Andy Shevchenko
2023-08-15 18:42 ` Bartosz Golaszewski
2023-08-15 18:38 ` Bartosz Golaszewski
2023-08-17 9:17 ` Andy Shevchenko
2023-08-21 21:15 ` Bartosz Golaszewski
2023-08-12 19:44 ` [PATCH 2/4] genirq/irq_sim: order includes alphabetically Bartosz Golaszewski
2023-08-15 10:39 ` Andy Shevchenko
2023-08-12 19:44 ` [PATCH 3/4] bitmap: define a cleanup function for bitmaps Bartosz Golaszewski
2023-08-14 1:02 ` Yury Norov
2023-08-14 7:13 ` Bartosz Golaszewski
2023-08-12 19:44 ` [PATCH 4/4] genirq/irq_sim: shrink code by using cleanup helpers Bartosz Golaszewski
2023-08-14 1:09 ` Yury Norov [this message]
2023-08-14 6:58 ` Bartosz Golaszewski
2023-09-12 8:55 [PATCH 0/4] genirq/irq_sim: misc updates Bartosz Golaszewski
2023-09-12 8:55 ` [PATCH 4/4] genirq/irq_sim: shrink code by using cleanup helpers Bartosz Golaszewski
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=ZNl+uKweuqJKaMcb@yury-ThinkPad \
--to=yury.norov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®