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: <Y2lMdQ/bE2w4skOO@google.com>
Date:   Mon, 7 Nov 2022 10:20:37 -0800
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Bartosz Golaszewski <brgl@...ev.pl>, linux-gpio@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v1 2/2] gpiolib: of: Integrate
 of_gpiochip_init_valid_mask() into gpiochip_init_valid_mask()

Hi Andy,

On Mon, Nov 07, 2022 at 06:10:27PM +0200, Andy Shevchenko wrote:
> +static unsigned int gpiochip_count_reserved_ranges(struct gpio_chip *gc)
> +{
> +	int size;
> +
> +	size = fwnode_property_count_u32(gc->fwnode, "gpio-reserved-ranges");

I wonder if a comment why we need even size would not be helpful.

> +	if (size > 0 && size % 2 == 0)
> +		return size;
> +
> +	return 0;
> +}
> +
>  static int gpiochip_alloc_valid_mask(struct gpio_chip *gc)
>  {
> -	if (!(of_gpio_need_valid_mask(gc) || gc->init_valid_mask))
> +	if (!(gpiochip_count_reserved_ranges(gc) || gc->init_valid_mask))
>  		return 0;
>  
>  	gc->valid_mask = gpiochip_allocate_mask(gc);
> @@ -457,8 +468,47 @@ static int gpiochip_alloc_valid_mask(struct gpio_chip *gc)
>  	return 0;
>  }
>  
> +static int gpiochip_apply_reserved_ranges(struct gpio_chip *gc, unsigned int sz)
> +{
> +	u32 *ranges;
> +	int ret;
> +
> +	ranges = kmalloc_array(sz, sizeof(*ranges), GFP_KERNEL);
> +	if (!ranges)
> +		return -ENOMEM;
> +
> +	ret = fwnode_property_read_u32_array(gc->fwnode, "gpio-reserved-ranges", ranges, sz);
> +	if (ret) {
> +		kfree(ranges);
> +		return ret;
> +	}
> +
> +	while (sz) {
> +		u32 count = ranges[--sz];
> +		u32 start = ranges[--sz];

I know we checked sz validity, but I wonder if re-checking it in this
function would not insulate us from errors creeping in after some other
code refactoring.

In any case,

Reviewed-by: Dmitry Torokhov <dmitry.torokhov@...il.com>

Thanks.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ