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: <20190604164558.GO9224@smile.fi.intel.com>
Date:   Tue, 4 Jun 2019 19:45:58 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Stefan Roese <sr@...x.de>
Cc:     linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Yegor Yefremov <yegorslists@...glemail.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Giulio Benetti <giulio.benetti@...ronovasrl.com>,
        Johan Hovold <johan@...nel.org>
Subject: Re: [PATCH 1/2 v4] serial: mctrl_gpio: Check if GPIO property
 exisits before requesting it

On Mon, Jun 03, 2019 at 10:33:31AM +0200, Stefan Roese wrote:
> This patch adds a check for the GPIOs property existence, before the
> GPIO is requested. This fixes an issue seen when the 8250 mctrl_gpio
> support is added (2nd patch in this patch series) on x86 platforms using
> ACPI.

>  	for (i = 0; i < UART_GPIO_MAX; i++) {
>  		enum gpiod_flags flags;
> +		char *gpio_str;
> +
> +		/* Check if GPIO property exists and continue if not */
> +		gpio_str = kasprintf(GFP_KERNEL, "%s-gpios",
> +				     mctrl_gpios_desc[i].name);
> +		if (!device_property_present(dev, gpio_str)) {
> +			kfree(gpio_str);
> +			continue;
> +		}
> +		kfree(gpio_str);

Can we rather do something like

	bool present;


	... = kasprintf(...);
// (1)
	present = device_property_present(...);
	kfree(...);
	if (!present)
		continue;

?

On top of this, if gpio_str is NULL, we will have KABOOM.

Something like

	if (!gpio_str)
		continue;

in (1).

>  
>  		if (mctrl_gpios_desc[i].dir_out)
>  			flags = GPIOD_OUT_LOW;

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ