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: <ZQBGlSnx3McF8m2r@smile.fi.intel.com>
Date:   Tue, 12 Sep 2023 14:08:05 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Bartosz Golaszewski <brgl@...ev.pl>
Cc:     Linus Walleij <linus.walleij@...aro.org>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-acpi@...r.kernel.org,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH v2 07/11] gpiolib: replace find_chip_by_name() with
 gpio_device_find_by_label()

On Tue, Sep 12, 2023 at 12:07:23PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
> 
> Remove all remaining uses of find_chip_by_name() (and subsequently:
> gpiochip_find()) from gpiolib.c and use the new
> gpio_device_find_by_label() instead.

...

>  	for (hog = &hogs[0]; hog->chip_label; hog++) {
> +		struct gpio_device *gdev __free(gpio_device_put) = NULL;

In the loop?! How does it work when loop goes second iteration and so on?

>  		list_add_tail(&hog->list, &gpio_machine_hogs);
>  
>  		/*
>  		 * The chip may have been registered earlier, so check if it
>  		 * exists and, if so, try to hog the line now.
>  		 */
> -		gc = find_chip_by_name(hog->chip_label);
> -		if (gc)
> -			gpiochip_machine_hog(gc, hog);
> +		gdev = gpio_device_find_by_label(hog->chip_label);
> +		if (gdev)
> +			gpiochip_machine_hog(gpio_device_get_chip(gdev), hog);

So, do we expect the chip_label be different between hogs? Ah, seems so
as it covers _all_ hogs in the system.

>  	}

Even if the __free() scope works fine, I think this algorithm should be
revisited to make sure we have iterating only on hogs of the same chip.
Hence, the hogs should be placed into tree structure with a label being
the key in it.

...

> +		struct gpio_device *gdev __free(gpio_device_put) = NULL;

> +		gc = gpio_device_get_chip(gdev);

Similar wish here, perhaps maple tree can be utilized in the future for both of them.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ