lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=Md8nB1U--qcZxpcKVzxTcON2hi-pmsUKFn+aBEqHuBzcQ@mail.gmail.com>
Date: Thu, 20 Mar 2025 16:51:04 +0100
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Koichiro Den <koichiro.den@...onical.com>
Cc: linux-gpio@...r.kernel.org, geert+renesas@...der.be, 
	linus.walleij@...aro.org, maciej.borzecki@...onical.com, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6 3/9] gpio: aggregator: add aggr_alloc()/aggr_free()

On Sat, Mar 15, 2025 at 5:41 PM Koichiro Den <koichiro.den@...onical.com> wrote:
>
> Prepare for the upcoming configfs interface. These functions will be
> used by both the existing sysfs interface and the new configfs
> interface, reducing code duplication.
>
> No functional change.
>
> Signed-off-by: Koichiro Den <koichiro.den@...onical.com>
> ---
>  drivers/gpio/gpio-aggregator.c | 58 +++++++++++++++++++++-------------
>  1 file changed, 36 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
> index e026deb4ac64..2692a31e01ac 100644
> --- a/drivers/gpio/gpio-aggregator.c
> +++ b/drivers/gpio/gpio-aggregator.c
> @@ -36,12 +36,41 @@
>  struct gpio_aggregator {
>         struct gpiod_lookup_table *lookups;
>         struct platform_device *pdev;
> +       int id;
>         char args[];
>  };
>
>  static DEFINE_MUTEX(gpio_aggregator_lock);     /* protects idr */
>  static DEFINE_IDR(gpio_aggregator_idr);
>
> +static int aggr_alloc(struct gpio_aggregator **aggr, size_t arg_size)
> +{
> +       struct gpio_aggregator *new __free(kfree) = NULL;
> +       int ret;
> +
> +       new = kzalloc(sizeof(*new) + arg_size, GFP_KERNEL);

Please prefer declaring the auto variable and initializing it at the
same time. Should be:

struct gpio_aggregator *new __free(kfree) = kzalloc(...);

> +       if (!new)
> +               return -ENOMEM;
> +
> +       mutex_lock(&gpio_aggregator_lock);

If adding new code, please use lock guards.

Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ